Skip to content

Commit a570373

Browse files
committed
boards: add SIMCOM SIM868 module support
Signed-off-by: Ajay Bhargav <[email protected]>
1 parent f08294e commit a570373

File tree

4 files changed

+192
-0
lines changed

4 files changed

+192
-0
lines changed

boards.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,41 @@ quectelm56.upload.maximum_ram_size=96256
424424
quectelm56.upload.speed=460800
425425
quectelm56.upload.require_upload_port=true
426426
quectelm56.upload.wait_for_upload_port=true
427+
428+
# sim868 board definition
429+
sim868.name=SIMCOM SIM868 GSM Module
430+
431+
# build
432+
sim868.build.core=logicrom
433+
sim868.build.cpu=arm9ejs
434+
sim868.build.f_cpu=260000000
435+
sim868.build.board=SIMCOM_SIM868
436+
sim868.build.mcu=mt2503
437+
sim868.build.variant=sim868
438+
sim868.build.vid=0x0E8D
439+
sim868.build.pid=0x0003
440+
sim868.build.extra_flags=-DPLATFORM_SIM868=1
441+
sim868.build.logicromlib=logicrom
442+
sim868.build.ldscript=linkerscript.ld
443+
sim868.menu.debug.Release=Release
444+
sim868.menu.debug.Release.build.build_type=
445+
sim868.menu.debug.Debug=Debug
446+
sim868.menu.debug.Debug.build.build_type=_debug
447+
sim868.menu.stdio.none=None
448+
sim868.menu.stdio.none.build.stdio_port=
449+
sim868.menu.stdio.ttys0=Uart0 (/dev/ttyS0)
450+
sim868.menu.stdio.ttys0.build.stdio_port=/dev/ttyS0
451+
sim868.menu.stdio.ttys1=Uart1 (/dev/ttyS1)
452+
sim868.menu.stdio.ttys1.build.stdio_port=/dev/ttyS1
453+
sim868.menu.stdio.ttyusb=USB Uart (/dev/ttyUSB0)
454+
sim868.menu.stdio.ttyusb.build.stdio_port=/dev/ttyUSB0
455+
456+
# upload
457+
sim868.bootloader.tool=logicromflasher
458+
sim868.upload.tool=logicromflasher
459+
sim868.upload.protocol=logicromflasher
460+
sim868.upload.maximum_size=262144
461+
sim868.upload.maximum_ram_size=96256
462+
sim868.upload.speed=460800
463+
sim868.upload.require_upload_port=true
464+
sim868.upload.wait_for_upload_port=true

variants/sim868/pins_arduino.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright (c) 2011 Arduino. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
// API compatibility
20+
#include "variant.h"
21+

variants/sim868/variant.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright (c) Waybyte Solutions. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License..
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
*/
14+
15+
#include "Arduino.h"
16+
17+
#ifdef __cplusplus
18+
extern "C"
19+
{
20+
#endif
21+
22+
int g_ioHandles[GPIO_PIN_MAX];
23+
int g_ioModes[GPIO_PIN_MAX];
24+
25+
static const uint32_t adc_channel_map[6][2] = {
26+
{GPIO_PIN_MAX, ADC_CH0},
27+
};
28+
29+
static const uint32_t pwm_channel_map[2][2] = {
30+
{GPIO_5, PWM_CH0},
31+
{GPIO_26, PWM_CH1},
32+
};
33+
34+
int pin2adc_channel(uint32_t pin)
35+
{
36+
for (int i = 0; i < 6; i++) {
37+
if (adc_channel_map[i][0] == pin)
38+
return adc_channel_map[i][1];
39+
}
40+
41+
return -1;
42+
}
43+
44+
int pin2pwm_channel(uint32_t pin)
45+
{
46+
for (int i = 0; i < 2; i++) {
47+
if (pwm_channel_map[i][0] == pin)
48+
return pwm_channel_map[i][1];
49+
}
50+
51+
return -1;
52+
}
53+
54+
#ifdef __cplusplus
55+
}
56+
#endif
57+
58+
void variant_init(void)
59+
{
60+
/* variant init */
61+
}

variants/sim868/variant.h

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#ifndef _VARIANT_MC20U_X_
2+
#define _VARIANT_MC20U_X_
3+
4+
/*
5+
* Headers
6+
*/
7+
#include <lib.h>
8+
#include <utils.h>
9+
#include <os_api.h>
10+
#include <hw/gpio.h>
11+
#include <hw/adc.h>
12+
#include <hw/pwm.h>
13+
#include <hw/i2c.h>
14+
#include <hw/spi.h>
15+
16+
#include <ril.h>
17+
18+
/* Default Definitions */
19+
#define VARIANT_MCK 260000000
20+
#define PWM_FREQUENCY 1000
21+
#ifndef DEFAULT_STDIO_PORT
22+
#define DEFAULT_STDIO_PORT "/dev/ttyUSB0"
23+
#endif
24+
25+
#define SPI_MAX_SPEED 10000000UL
26+
27+
/* Analog Pin definition */
28+
#define A0 GPIO_PIN_MAX
29+
30+
/* LED */
31+
#define LED_BUILTIN GPIO_5
32+
33+
/*
34+
* SPI Interfaces
35+
*/
36+
#define SPI_INTERFACES_COUNT 1
37+
#define PIN_SPI_SS0 (GPIO_4)
38+
#define PIN_SPI_MOSI (GPIO_15)
39+
#define PIN_SPI_MISO (GPIO_14)
40+
#define PIN_SPI_SCK (GPIO_6)
41+
#define BOARD_SPI_SS0 (PIN_SPI_SS0)
42+
43+
static const uint8_t SS = BOARD_SPI_SS0;
44+
static const uint8_t MOSI = PIN_SPI_MOSI;
45+
static const uint8_t MISO = PIN_SPI_MISO;
46+
static const uint8_t SCK = PIN_SPI_SCK;
47+
48+
/* For Variant.cpp */
49+
#define CHECK_MODE(pin, mode) ((g_ioModes[pin] & 0xff) == IO_MODE_##mode)
50+
51+
enum _io_mode {
52+
IO_MODE_GPIO = 1,
53+
IO_MODE_ADC = 2,
54+
IO_MODE_PWM = 3,
55+
};
56+
57+
#ifdef __cplusplus
58+
extern "C"
59+
{
60+
#endif
61+
62+
extern int g_ioHandles[GPIO_PIN_MAX];
63+
extern int g_ioModes[GPIO_PIN_MAX];
64+
65+
int pin2adc_channel(uint32_t pin);
66+
int pin2pwm_channel(uint32_t pin);
67+
68+
#ifdef __cplusplus
69+
}
70+
#endif
71+
72+
#endif

0 commit comments

Comments
 (0)