Skip to content

Commit 2dfcc42

Browse files
committed
Add support for Quectel M66 2G GSM Module
Signed-off-by: Ajay Bhargav <[email protected]>
1 parent 3b30687 commit 2dfcc42

File tree

5 files changed

+291
-0
lines changed

5 files changed

+291
-0
lines changed

boards.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,37 @@ s20gsm.upload.maximum_ram_size=96256
4141
s20gsm.upload.speed=460800
4242
s20gsm.upload.require_upload_port=true
4343
s20gsm.upload.wait_for_upload_port=true
44+
45+
# Quectel M66
46+
quectelm66.name=Quectel M66
47+
48+
# build
49+
quectelm66.build.core=siwigsm
50+
quectelm66.build.cpu=arm9ejs
51+
quectelm66.build.f_cpu=260000000
52+
quectelm66.build.board=QUECTEL_M66TEA
53+
quectelm66.build.mcu=mt6261
54+
quectelm66.build.variant=m66
55+
quectelm66.build.extra_flags=-DPLATFORM_M66=1
56+
quectelm66.build.ldscript=linkerscript.ld
57+
quectelm66.menu.debug.Release=Release
58+
quectelm66.menu.debug.Release.build.build_type=
59+
quectelm66.menu.debug.Debug=Debug
60+
quectelm66.menu.debug.Debug.build.build_type=_debug
61+
quectelm66.menu.stdio.ttys0=Uart0 (/dev/ttyS0)
62+
quectelm66.menu.stdio.ttys0.build.stdio_port=/dev/ttyS0
63+
quectelm66.menu.stdio.ttys1=Uart1 (/dev/ttyS1)
64+
quectelm66.menu.stdio.ttys1.build.stdio_port=/dev/ttyS1
65+
quectelm66.menu.stdio.ttys2=Uart2 (/dev/ttyS2)
66+
quectelm66.menu.stdio.ttys2.build.stdio_port=/dev/ttyS2
67+
68+
# upload
69+
quectelm66.bootloader.tool=siwiflasher
70+
quectelm66.upload.tool=siwiflasher
71+
quectelm66.upload.protocol=siwiflasher
72+
quectelm66.upload.maximum_size=262144
73+
quectelm66.upload.maximum_ram_size=96256
74+
quectelm66.upload.speed=460800
75+
quectelm66.upload.require_upload_port=true
76+
quectelm66.upload.wait_for_upload_port=true
77+

cores/siwigsm/HardwareSerial.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
HardwareSerial Serial(UART0);
1616
HardwareSerial Serial1(UART1);
1717
HardwareSerial Serial2(UART2);
18+
#if defined(PLATFORM_S20U)
1819
HardwareSerial USBSerial(USBUART);
20+
#endif
1921
HardwareSerial BTSerial(BTSPPHOST);
2022
#endif
2123

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

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

variants/m66/variant.h

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#ifndef _VARIANT_M66_X_
2+
#define _VARIANT_M66_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_7
29+
#define A3 GPIO_8
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_9)
39+
#define PIN_SPI_MISO (GPIO_10)
40+
#define PIN_SPI_SCK (GPIO_11)
41+
#define PIN_SPI_MOSI (GPIO_12)
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)