Skip to content

Commit 8d00360

Browse files
committed
Add support for Quectel MC60/MC20 2G GSM Module
Signed-off-by: Ajay Bhargav <[email protected]>
1 parent 2dfcc42 commit 8d00360

File tree

4 files changed

+327
-0
lines changed

4 files changed

+327
-0
lines changed

boards.txt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,68 @@ quectelm66.upload.speed=460800
7575
quectelm66.upload.require_upload_port=true
7676
quectelm66.upload.wait_for_upload_port=true
7777

78+
# Quectel MC60
79+
quectelmc60.name=Quectel MC60
80+
81+
# build
82+
quectelmc60.build.core=siwigsm
83+
quectelmc60.build.cpu=arm9ejs
84+
quectelmc60.build.f_cpu=260000000
85+
quectelmc60.build.board=QUECTEL_MC60TEA
86+
quectelmc60.build.mcu=mt2503
87+
quectelmc60.build.variant=mc60
88+
quectelmc60.build.extra_flags=-DPLATFORM_MC60=1
89+
quectelmc60.build.ldscript=linkerscript.ld
90+
quectelmc60.menu.debug.Release=Release
91+
quectelmc60.menu.debug.Release.build.build_type=
92+
quectelmc60.menu.debug.Debug=Debug
93+
quectelmc60.menu.debug.Debug.build.build_type=_debug
94+
quectelmc60.menu.stdio.ttys0=Uart0 (/dev/ttyS0)
95+
quectelmc60.menu.stdio.ttys0.build.stdio_port=/dev/ttyS0
96+
quectelmc60.menu.stdio.ttys1=Uart1 (/dev/ttyS1)
97+
quectelmc60.menu.stdio.ttys1.build.stdio_port=/dev/ttyS1
98+
quectelmc60.menu.stdio.ttys2=Uart2 (/dev/ttyS2)
99+
quectelmc60.menu.stdio.ttys2.build.stdio_port=/dev/ttyS2
100+
101+
# upload
102+
quectelmc60.bootloader.tool=siwiflasher
103+
quectelmc60.upload.tool=siwiflasher
104+
quectelmc60.upload.protocol=siwiflasher
105+
quectelmc60.upload.maximum_size=262144
106+
quectelmc60.upload.maximum_ram_size=96256
107+
quectelmc60.upload.speed=460800
108+
quectelmc60.upload.require_upload_port=true
109+
quectelmc60.upload.wait_for_upload_port=true
110+
111+
# Quectel MC20
112+
quectelmc20.name=Quectel MC20
113+
114+
# build
115+
quectelmc20.build.core=siwigsm
116+
quectelmc20.build.cpu=arm9ejs
117+
quectelmc20.build.f_cpu=260000000
118+
quectelmc20.build.board=QUECTEL_MC20TEA
119+
quectelmc20.build.mcu=mt2503
120+
quectelmc20.build.variant=mc60
121+
quectelmc20.build.extra_flags=-DPLATFORM_MC60=1
122+
quectelmc20.build.ldscript=linkerscript.ld
123+
quectelmc20.menu.debug.Release=Release
124+
quectelmc20.menu.debug.Release.build.build_type=
125+
quectelmc20.menu.debug.Debug=Debug
126+
quectelmc20.menu.debug.Debug.build.build_type=_debug
127+
quectelmc20.menu.stdio.ttys0=Uart0 (/dev/ttyS0)
128+
quectelmc20.menu.stdio.ttys0.build.stdio_port=/dev/ttyS0
129+
quectelmc20.menu.stdio.ttys1=Uart1 (/dev/ttyS1)
130+
quectelmc20.menu.stdio.ttys1.build.stdio_port=/dev/ttyS1
131+
quectelmc20.menu.stdio.ttys2=Uart2 (/dev/ttyS2)
132+
quectelmc20.menu.stdio.ttys2.build.stdio_port=/dev/ttyS2
133+
134+
# upload
135+
quectelmc20.bootloader.tool=siwiflasher
136+
quectelmc20.upload.tool=siwiflasher
137+
quectelmc20.upload.protocol=siwiflasher
138+
quectelmc20.upload.maximum_size=262144
139+
quectelmc20.upload.maximum_ram_size=96256
140+
quectelmc20.upload.speed=460800
141+
quectelmc20.upload.require_upload_port=true
142+
quectelmc20.upload.wait_for_upload_port=true

variants/mc60/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/mc60/variant.cpp

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/*
2+
Copyright (c) 2020 SiWi Embedded 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+
void serialEvent() __attribute__((weak));
18+
void serialEvent1() __attribute__((weak));
19+
20+
void serialEventRun(void)
21+
{
22+
/* TODO */
23+
}
24+
25+
#ifdef __cplusplus
26+
extern "C"
27+
{
28+
#endif
29+
30+
int g_ioHandles[GPIO_PIN_MAX];
31+
int g_ioModes[GPIO_PIN_MAX];
32+
33+
static const uint32_t adc_channel_map[6][2] = {
34+
{GPIO_1, ADC_CH1},
35+
{GPIO_27, ADC_CH2},
36+
{GPIO_28, ADC_CH3},
37+
{GPIO_PIN_MAX, ADC_CH0},
38+
};
39+
40+
static const uint32_t pwm_channel_map[2][2] = {
41+
{GPIO_1, PWM_CH0},
42+
{GPIO_32, PWM_CH1},
43+
};
44+
45+
int pin2adc_channel(uint32_t pin)
46+
{
47+
for (int i = 0; i < 6; i++) {
48+
if (adc_channel_map[i][0] == pin)
49+
return adc_channel_map[i][1];
50+
}
51+
52+
return -1;
53+
}
54+
55+
int pin2pwm_channel(uint32_t pin)
56+
{
57+
for (int i = 0; i < 2; i++) {
58+
if (pwm_channel_map[i][0] == pin)
59+
return pwm_channel_map[i][1];
60+
}
61+
62+
return -1;
63+
}
64+
65+
#ifdef __cplusplus
66+
}
67+
#endif
68+
69+
static void urc_callback(unsigned int param1, unsigned int param2)
70+
{
71+
switch (param1)
72+
{
73+
case URC_SYS_INIT_STATE_IND:
74+
if (param2 == SYS_STATE_SMSOK)
75+
{
76+
/* Ready for SMS */
77+
}
78+
break;
79+
case URC_SIM_CARD_STATE_IND:
80+
switch (param2)
81+
{
82+
case SIM_STAT_NOT_INSERTED:
83+
debug(DBG_OFF, "SYSTEM: SIM card not inserted!\n");
84+
break;
85+
case SIM_STAT_READY:
86+
debug(DBG_INFO, "SYSTEM: SIM card Ready!\n");
87+
break;
88+
case SIM_STAT_PIN_REQ:
89+
debug(DBG_OFF, "SYSTEM: SIM PIN required!\n");
90+
break;
91+
case SIM_STAT_PUK_REQ:
92+
debug(DBG_OFF, "SYSTEM: SIM PUK required!\n");
93+
break;
94+
case SIM_STAT_NOT_READY:
95+
debug(DBG_OFF, "SYSTEM: SIM card not recognized!\n");
96+
break;
97+
default:
98+
debug(DBG_OFF, "SYSTEM: SIM ERROR: %d\n", param2);
99+
}
100+
break;
101+
case URC_GSM_NW_STATE_IND:
102+
debug(DBG_OFF, "SYSTEM: GSM NW State: %d\n", param2);
103+
break;
104+
case URC_GPRS_NW_STATE_IND:
105+
break;
106+
case URC_CFUN_STATE_IND:
107+
break;
108+
case URC_COMING_CALL_IND:
109+
debug(DBG_OFF, "Incoming voice call from: %s\n", ((ST_ComingCall *)param2)->phoneNumber);
110+
/* Take action here, Answer/Hang-up */
111+
break;
112+
case URC_CALL_STATE_IND:
113+
switch (param2)
114+
{
115+
case CALL_STATE_BUSY:
116+
debug(DBG_OFF, "The number you dialed is busy now\n");
117+
break;
118+
case CALL_STATE_NO_ANSWER:
119+
debug(DBG_OFF, "The number you dialed has no answer\n");
120+
break;
121+
case CALL_STATE_NO_CARRIER:
122+
debug(DBG_OFF, "The number you dialed cannot reach\n");
123+
break;
124+
case CALL_STATE_NO_DIALTONE:
125+
debug(DBG_OFF, "No Dial tone\n");
126+
break;
127+
default:
128+
break;
129+
}
130+
break;
131+
case URC_NEW_SMS_IND:
132+
debug(DBG_OFF, "SMS: New SMS (%d)\n", param2);
133+
/* Handle New SMS */
134+
break;
135+
case URC_MODULE_VOLTAGE_IND:
136+
debug(DBG_INFO, "VBatt Voltage: %d\n", param2);
137+
break;
138+
case URC_ALARM_RING_IND:
139+
break;
140+
case URC_FILE_DOWNLOAD_STATUS:
141+
break;
142+
case URC_FOTA_STARTED:
143+
break;
144+
case URC_FOTA_FINISHED:
145+
break;
146+
case URC_FOTA_FAILED:
147+
break;
148+
case URC_STKPCI_RSP_IND:
149+
break;
150+
default:
151+
break;
152+
}
153+
}
154+
155+
/*
156+
* \brief Main entry point of Arduino application
157+
*/
158+
int main(int argc, char *argv[])
159+
{
160+
/* Initialize Siwi system task */
161+
siwilib_init(DEFAULT_STDIO_PORT, urc_callback);
162+
163+
setup();
164+
for (;;)
165+
{
166+
loop();
167+
}
168+
}

variants/mc60/variant.h

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#ifndef _VARIANT_MC60_X_
2+
#define _VARIANT_MC60_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/ttyS0"
23+
#endif
24+
25+
/* Analog Pin definition */
26+
#define A0 GPIO_PIN_MAX
27+
#define A1 GPIO_1
28+
#define A2 GPIO_27
29+
#define A3 GPIO_28
30+
31+
/* LED */
32+
#define LED_BUILTIN GPIO_1
33+
34+
/*
35+
* SPI Interfaces
36+
*/
37+
#define SPI_INTERFACES_COUNT 1
38+
#define PIN_SPI_SS0 (GPIO_7)
39+
#define PIN_SPI_MISO (GPIO_8)
40+
#define PIN_SPI_SCK (GPIO_9)
41+
#define PIN_SPI_MOSI (GPIO_10)
42+
#define BOARD_SPI_SS0 (PIN_SPI_SS0)
43+
44+
static const uint8_t SS = BOARD_SPI_SS0;
45+
static const uint8_t MOSI = PIN_SPI_MOSI;
46+
static const uint8_t MISO = PIN_SPI_MISO;
47+
static const uint8_t SCK = PIN_SPI_SCK;
48+
49+
/* For Variant.cpp */
50+
#define CHECK_MODE(pin, mode) ((g_ioModes[pin] & 0xff) == IO_MODE_##mode)
51+
52+
enum _io_mode {
53+
IO_MODE_GPIO = 1,
54+
IO_MODE_ADC = 2,
55+
IO_MODE_PWM = 3,
56+
};
57+
58+
#ifdef __cplusplus
59+
extern "C"
60+
{
61+
#endif
62+
63+
extern int g_ioHandles[GPIO_PIN_MAX];
64+
extern int g_ioModes[GPIO_PIN_MAX];
65+
66+
int pin2adc_channel(uint32_t pin);
67+
int pin2pwm_channel(uint32_t pin);
68+
69+
#ifdef __cplusplus
70+
}
71+
#endif
72+
73+
#endif

0 commit comments

Comments
 (0)