Skip to content

Commit 45ad481

Browse files
committed
Add LoRa pins definition
LoRa module tested with this library: https://github.com/sandeepmistry/arduino-LoRa Config to add in arduino-LoRa example sketches: SPI.setMISO(RADIO_MISO_PORT); SPI.setMOSI(RADIO_MOSI_PORT); SPI.setSCLK(RADIO_SCLK_PORT); SPI.setSSEL(RADIO_NSS_PORT); LoRa.setPins(RADIO_NSS_PORT, RADIO_RESET_PORT, RADIO_DIO_0_PORT); Note that a PR is under review for arduino-LoRa library to be able to change the SPI instance used. So, instead of changing SPI pins, a new instance could be created: SPIClass LoRaSPI(RADIO_MOSI_PORT, RADIO_MISO_PORT, RADIO_SCLK_PORT, RADIO_NSS_PORT); LoRa.setSPI(LoRaSPI); LoRa.setPins(RADIO_NSS_PORT, RADIO_RESET_PORT, RADIO_DIO_0_PORT); Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parent c392140 commit 45ad481

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

variants/DISCO_L072CZ_LRWAN1/PeripheralPins.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ const PinMap PinMap_UART_CTS[] = {
192192

193193
#ifdef HAL_SPI_MODULE_ENABLED
194194
const PinMap PinMap_SPI_MOSI[] = {
195-
// {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, // Not available on board
195+
{PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, // RADIO_MOSI_PORT
196196
{PA_12, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)},
197197
{PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)},
198198
{PB_15, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)},
@@ -202,7 +202,7 @@ const PinMap PinMap_SPI_MOSI[] = {
202202

203203
#ifdef HAL_SPI_MODULE_ENABLED
204204
const PinMap PinMap_SPI_MISO[] = {
205-
// {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, // Not available on board
205+
{PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, // RADIO_MISO_PORT
206206
{PA_11, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)},
207207
// {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, // Not available on board
208208
{PB_14, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)},
@@ -214,7 +214,7 @@ const PinMap PinMap_SPI_MISO[] = {
214214
#ifdef HAL_SPI_MODULE_ENABLED
215215
const PinMap PinMap_SPI_SCLK[] = {
216216
{PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)},
217-
// {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, // Not available on board
217+
{PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, // RADIO_SCLK_PORT
218218
// {PB_10, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)}, // Not available on board
219219
{PB_13, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)},
220220
{NC, NP, 0}
@@ -224,7 +224,7 @@ const PinMap PinMap_SPI_SCLK[] = {
224224
#ifdef HAL_SPI_MODULE_ENABLED
225225
const PinMap PinMap_SPI_SSEL[] = {
226226
{PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)},
227-
// {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, // Not available on board
227+
{PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, // RADIO_NSS_PORT
228228
{PB_9, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
229229
{PB_12, SPI2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)},
230230
{NC, NP, 0}

variants/DISCO_L072CZ_LRWAN1/variant.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,20 @@ const PinName digitalPin[] = {
5555
PA_11, //D25
5656
PA_0, //D26/A0
5757
PA_0, //D27/A1 - alias for A0 - requires closing solder bridge SB7
58-
PA_4, //D28/A2
58+
PA_4, //D28/A2 - RADIO_DIO_5_PORT
5959
PA_4, //D29/A3 - alias for A2 - requires closing solder bridge SB8
6060
PB_9, //D30/A4 - requires closing solder bridge SB11
6161
PB_8, //D31/A5 - requires closing solder bridge SB12
62-
PA_5, //D32/A6
62+
PA_5, //D32/A6 - RADIO_DIO_4_PORT
63+
PC_0, //D33 - RADIO_RESET_PORT
64+
PA_7, //D34 - RADIO_MOSI_PORT
65+
PA_6, //D35 - RADIO_MISO_PORT
66+
PB_3, //D36 - RADIO_SCLK_PORT
67+
PA_15, //D37 - RADIO_NSS_PORT
68+
PB_4, //D38 - RADIO_DIO_0_PORT
69+
PB_1, //D39 - RADIO_DIO_1_PORT
70+
PB_0, //D40 - RADIO_DIO_2_PORT
71+
PC_13, //D41 - RADIO_DIO_3_PORT
6372
};
6473

6574
#ifdef __cplusplus

variants/DISCO_L072CZ_LRWAN1/variant.h

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,25 @@ enum {
6464
PA11, //D25
6565
PA0, //D26/A0
6666
PA0_2,//D27/A1 - alias for A0 - requires closing solder bridge SB7
67-
PA4, //D28/A2
67+
PA4, //D28/A2 - RADIO_DIO_5_PORT
6868
PA4_2,//D29/A3 - alias for A2 - requires closing solder bridge SB8
6969
PB9_2,//D30/A4 - requires closing solder bridge SB11
7070
PB8_2,//D31/A5 - requires closing solder bridge SB12
71-
PA5, //D32/A6
71+
PA5, //D32/A6 - RADIO_DIO_4_PORT
72+
PC0, //D33 - RADIO_RESET_PORT
73+
PA7, //D34 - RADIO_MOSI_PORT
74+
PA6, //D35 - RADIO_MISO_PORT
75+
PB3, //D36 - RADIO_SCLK_PORT
76+
PA15, //D37 - RADIO_NSS_PORT
77+
PB4, //D38 - RADIO_DIO_0_PORT
78+
PB1, //D39 - RADIO_DIO_1_PORT
79+
PB0, //D40 - RADIO_DIO_2_PORT
80+
PC13, //D41 - RADIO_DIO_3_PORT
7281
PEND
7382
};
7483

7584
// This must be a literal with the same value as PEND
76-
#define NUM_DIGITAL_PINS 33
85+
#define NUM_DIGITAL_PINS 42
7786
// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS
7887
#define NUM_ANALOG_INPUTS 7
7988
#define NUM_ANALOG_FIRST 26
@@ -92,8 +101,21 @@ enum {
92101
// On-board user button
93102
#define USER_BTN 6
94103

95-
// Timer Definitions
96-
// Do not use timer used by PWM pins when possible. See PinMap_PWM.
104+
// LORA
105+
#define RADIO_RESET_PORT PC0
106+
#define RADIO_MOSI_PORT PA7
107+
#define RADIO_MISO_PORT PA6
108+
#define RADIO_SCLK_PORT PB3
109+
#define RADIO_NSS_PORT PA15
110+
#define RADIO_DIO_0_PORT PB4
111+
#define RADIO_DIO_1_PORT PB1
112+
#define RADIO_DIO_2_PORT PB0
113+
#define RADIO_DIO_3_PORT PC13
114+
#define RADIO_DIO_4_PORT PA5
115+
#define RADIO_DIO_5_PORT PA4
116+
117+
//Timer Definitions
118+
//Do not use timer used by PWM pins when possible. See PinMap_PWM.
97119
#define TIMER_TONE TIM22
98120

99121
// Do not use basic timer: OC is required

0 commit comments

Comments
 (0)