Skip to content

Commit 633606a

Browse files
authored
Merge pull request #1253 from fpistm/updateG0
Update STM32G0 HAL and CMSIS drivers
2 parents 4b8fd08 + 54213f4 commit 633606a

File tree

215 files changed

+94900
-7621
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+94900
-7621
lines changed

Diff for: CI/utils/patch/HAL/G0/0001-G0-Fix-HAL-definition.patch

-29
This file was deleted.

Diff for: boards.txt

+8
Original file line numberDiff line numberDiff line change
@@ -5771,6 +5771,14 @@ GenG4.menu.xusb.HS.build.usb_speed=-DUSE_USB_HS
57715771
GenG4.menu.xusb.HSFS=High Speed in Full Speed mode
57725772
GenG4.menu.xusb.HSFS.build.usb_speed=-DUSE_USB_HS -DUSE_USB_HS_IN_FS
57735773

5774+
GenG0.menu.usb.none=None
5775+
GenG0.menu.usb.CDCgen=CDC (generic 'Serial' supersede U(S)ART)
5776+
GenG0.menu.usb.CDCgen.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC
5777+
GenG0.menu.usb.CDC=CDC (no generic 'Serial')
5778+
GenG0.menu.usb.CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DDISABLE_GENERIC_SERIALUSB
5779+
GenG0.menu.usb.HID=HID (keyboard and mouse)
5780+
GenG0.menu.usb.HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE
5781+
57745782
GenH7.menu.usb.none=None
57755783
GenH7.menu.usb.CDCgen=CDC (generic 'Serial' supersede U(S)ART)
57765784
GenH7.menu.usb.CDCgen.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC

Diff for: cores/arduino/HardwareSerial.cpp

+19-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#if defined(HAVE_HWSERIAL1) || defined(HAVE_HWSERIAL2) || defined(HAVE_HWSERIAL3) ||\
3131
defined(HAVE_HWSERIAL4) || defined(HAVE_HWSERIAL5) || defined(HAVE_HWSERIAL6) ||\
3232
defined(HAVE_HWSERIAL7) || defined(HAVE_HWSERIAL8) || defined(HAVE_HWSERIAL9) ||\
33-
defined(HAVE_HWSERIAL10) || defined(HAVE_HWSERIALLP1)
33+
defined(HAVE_HWSERIAL10) || defined(HAVE_HWSERIALLP1) || defined(HAVE_HWSERIALLP2)
3434
// SerialEvent functions are weak, so when the user doesn't define them,
3535
// the linker just sets their address to 0 (which is checked below).
3636
#if defined(HAVE_HWSERIAL1)
@@ -107,6 +107,11 @@
107107
HardwareSerial SerialLP1(LPUART1);
108108
void serialEventLP1() __attribute__((weak));
109109
#endif
110+
111+
#if defined(HAVE_HWSERIALLP2)
112+
HardwareSerial SerialLP2(LPUART2);
113+
void serialEventLP2() __attribute__((weak));
114+
#endif
110115
#endif // HAVE_HWSERIALx
111116

112117
// Constructors ////////////////////////////////////////////////////////////////
@@ -252,11 +257,19 @@ HardwareSerial::HardwareSerial(void *peripheral, HalfDuplexMode_t halfDuplex)
252257
setTx(PIN_SERIALLP1_TX);
253258
} else
254259
#endif
255-
// else get the pins of the first peripheral occurence in PinMap
256-
{
257-
_serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX);
258-
_serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX);
259-
}
260+
#if defined(PIN_SERIALLP2_TX) && defined(LPUART2_BASE)
261+
if (peripheral == LPUART2) {
262+
#if defined(PIN_SERIALLP2_RX)
263+
setRx(PIN_SERIALLP2_RX);
264+
#endif
265+
setTx(PIN_SERIALLP2_TX);
266+
} else
267+
#endif
268+
// else get the pins of the first peripheral occurence in PinMap
269+
{
270+
_serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX);
271+
_serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX);
272+
}
260273
if (halfDuplex == HALF_DUPLEX_ENABLED) {
261274
_serial.pin_rx = NC;
262275
}

Diff for: cores/arduino/HardwareSerial.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,7 @@ class HardwareSerial : public Stream {
207207
#if defined(LPUART1)
208208
extern HardwareSerial SerialLP1;
209209
#endif
210-
210+
#if defined(LPUART2)
211+
extern HardwareSerial SerialLP2;
212+
#endif
211213
#endif

Diff for: cores/arduino/HardwareTimer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,11 @@ extern "C" {
14891489
if (HardwareTimer_Handle[TIMER3_INDEX]) {
14901490
HAL_TIM_IRQHandler(&HardwareTimer_Handle[TIMER3_INDEX]->handle);
14911491
}
1492+
#if defined(STM32G0xx) && defined(TIM4_BASE)
1493+
if (HardwareTimer_Handle[TIMER4_INDEX]) {
1494+
HAL_TIM_IRQHandler(&HardwareTimer_Handle[TIMER4_INDEX]->handle);
1495+
}
1496+
#endif
14921497
}
14931498
#endif //TIM3_BASE
14941499

Diff for: cores/arduino/WSerial.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ WEAK void serialEventRun(void)
5757
serialEventLP1();
5858
}
5959
#endif
60+
#if defined(HAVE_HWSERIALLP2)
61+
if (serialEventLP2 && SerialLP2.available()) {
62+
serialEventLP2();
63+
}
64+
#endif
6065
#if defined(HAVE_SERIALUSB)
6166
if (serialEventUSB && SerialUSB.available()) {
6267
serialEventUSB();

Diff for: cores/arduino/WSerial.h

+14
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
#define Serial SerialLP1
4747
#define serialEvent serialEventLP1
4848
#endif
49+
#elif SERIAL_UART_INSTANCE == 102
50+
#define ENABLE_HWSERIALLP2
51+
#if !defined(Serial)
52+
#define Serial SerialLP2
53+
#define serialEvent serialEventLP2
54+
#endif
4955
#elif SERIAL_UART_INSTANCE == 1
5056
#define ENABLE_HWSERIAL1
5157
#if !defined(Serial)
@@ -118,6 +124,11 @@
118124
#define HAVE_HWSERIALLP1
119125
#endif
120126
#endif
127+
#if defined(ENABLE_HWSERIALLP2)
128+
#if defined(LPUART2_BASE)
129+
#define HAVE_HWSERIALLP2
130+
#endif
131+
#endif
121132
#if defined(ENABLE_HWSERIAL1)
122133
#if defined(USART1_BASE)
123134
#define HAVE_HWSERIAL1
@@ -202,6 +213,9 @@
202213
#if defined(HAVE_HWSERIALLP1)
203214
extern void serialEventLP1(void) __attribute__((weak));
204215
#endif
216+
#if defined(HAVE_HWSERIALLP2)
217+
extern void serialEventLP2(void) __attribute__((weak));
218+
#endif
205219
#endif /* HAL_UART_MODULE_ENABLED && !HAL_UART_MODULE_ONLY */
206220

207221
extern void serialEventRun(void);

Diff for: cores/arduino/stm32/LL/stm32yyxx_ll_crs.h

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
#ifdef STM32F0xx
99
#include "stm32f0xx_ll_crs.h"
1010
#endif
11+
#ifdef STM32G0xx
12+
#include "stm32g0xx_ll_crs.h"
13+
#endif
1114
#ifdef STM32G4xx
1215
#include "stm32g4xx_ll_crs.h"
1316
#endif

Diff for: cores/arduino/stm32/LL/stm32yyxx_ll_usb.h

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#ifdef STM32F7xx
2424
#include "stm32f7xx_ll_usb.h"
2525
#endif
26+
#ifdef STM32G0xx
27+
#include "stm32g0xx_ll_usb.h"
28+
#endif
2629
#ifdef STM32G4xx
2730
#include "stm32g4xx_ll_usb.h"
2831
#endif

Diff for: cores/arduino/stm32/stm32_def.h

+6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@
6565
#define CAN1 CAN
6666
#endif
6767

68+
/* STM32G0xx defined USB_DRD_FS */
69+
#if !defined(USB ) && defined(USB_DRD_FS)
70+
#define USB USB_DRD_FS
71+
#define PinMap_USB PinMap_USB_DRD_FS
72+
#endif
73+
6874
/**
6975
* Libc porting layers
7076
*/

Diff for: cores/arduino/stm32/stm32_def_build.h

+12
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,24 @@
178178
#define CMSIS_STARTUP_FILE "startup_stm32g031xx.s"
179179
#elif defined(STM32G041xx)
180180
#define CMSIS_STARTUP_FILE "startup_stm32g041xx.s"
181+
#elif defined(STM32G050xx)
182+
#define CMSIS_STARTUP_FILE "startup_stm32g050xx.s"
183+
#elif defined(STM32G051xx)
184+
#define CMSIS_STARTUP_FILE "startup_stm32g051xx.s"
185+
#elif defined(STM32G061xx)
186+
#define CMSIS_STARTUP_FILE "startup_stm32g061xx.s"
181187
#elif defined(STM32G070xx)
182188
#define CMSIS_STARTUP_FILE "startup_stm32g070xx.s"
183189
#elif defined(STM32G071xx)
184190
#define CMSIS_STARTUP_FILE "startup_stm32g071xx.s"
185191
#elif defined(STM32G081xx)
186192
#define CMSIS_STARTUP_FILE "startup_stm32g081xx.s"
193+
#elif defined(STM32G0B0xx)
194+
#define CMSIS_STARTUP_FILE "startup_stm32g0b0xx.s"
195+
#elif defined(STM32G0B1xx)
196+
#define CMSIS_STARTUP_FILE "startup_stm32g0b1xx.s"
197+
#elif defined(STM32G0C1xx)
198+
#define CMSIS_STARTUP_FILE "startup_stm32g0c1xx.s"
187199
#elif defined(STM32G431xx)
188200
#define CMSIS_STARTUP_FILE "startup_stm32g431xx.s"
189201
#elif defined(STM32G441xx)

Diff for: cores/arduino/stm32/timer.h

+19
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ extern "C" {
6464
#endif
6565
#endif
6666

67+
#if defined(TIM3_BASE) && !defined(TIM3_IRQn)
68+
#if defined(STM32G0xx) && defined(TIM4_BASE)
69+
#define TIM3_IRQn TIM3_TIM4_IRQn
70+
#define TIM3_IRQHandler TIM3_TIM4_IRQHandler
71+
#endif
72+
#endif
73+
74+
#if defined(TIM4_BASE) && !defined(TIM4_IRQn)
75+
#if defined(STM32G0xx)
76+
#define TIM4_IRQn TIM3_TIM4_IRQn
77+
#endif
78+
#endif
79+
6780
#if defined(TIM6_BASE) && !defined(TIM6_IRQn)
6881
#if defined(DAC_BASE) || defined(DAC1_BASE)
6982
#if defined(STM32G0xx)
@@ -147,13 +160,19 @@ extern "C" {
147160
defined(STM32WBxx)
148161
#define TIM16_IRQn TIM1_UP_TIM16_IRQn
149162
//TIM16_IRQHandler is mapped on TIM1_IRQHandler when TIM16_IRQn is not defined
163+
#elif defined(STM32G0xx) && defined(FDCAN1_BASE)
164+
#define TIM16_IRQn TIM16_FDCAN_IT0_IRQn
165+
#define TIM16_IRQHandler TIM16_FDCAN_IT0_IRQHandler
150166
#endif
151167
#endif
152168
#if defined(TIM17_BASE) && !defined(TIM17_IRQn)
153169
#if defined(STM32F1xx) || defined(STM32F3xx) || defined(STM32G4xx) || defined(STM32L4xx) || \
154170
defined(STM32WBxx)
155171
#define TIM17_IRQn TIM1_TRG_COM_TIM17_IRQn
156172
#define TIM17_IRQHandler TIM1_TRG_COM_TIM17_IRQHandler
173+
#elif defined(STM32G0xx) && defined(FDCAN1_BASE)
174+
#define TIM17_IRQn TIM17_FDCAN_IT1_IRQn
175+
#define TIM17_IRQHandler TIM17_FDCAN_IT1_IRQHandler
157176
#endif
158177
#endif
159178
#if defined(TIM18_BASE) && !defined(TIM18_IRQn)

Diff for: cores/arduino/stm32/uart.h

+45-12
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ struct serial_s {
8686
/* Exported constants --------------------------------------------------------*/
8787
#define TX_TIMEOUT 1000
8888

89+
#if defined(USART2_BASE) && !defined(USART2_IRQn)
90+
#if defined(STM32G0xx)
91+
#if defined(LPUART2_BASE)
92+
#define USART2_IRQn USART2_LPUART2_IRQn
93+
#define USART2_IRQHandler USART2_LPUART2_IRQHandler
94+
#endif
95+
#endif /* STM32G0xx */
96+
#endif
97+
8998
#if defined(USART3_BASE) && !defined(USART3_IRQn)
9099
#if defined(STM32F0xx)
91100
#if defined(STM32F091xC) || defined (STM32F098xx)
@@ -98,17 +107,18 @@ struct serial_s {
98107
#define USART3_IRQn USART3_4_IRQn
99108
#define USART3_IRQHandler USART3_4_IRQHandler
100109
#endif /* STM32F091xC || STM32F098xx */
101-
#endif /* STM32F0xx */
102-
103-
#if defined(STM32G0xx)
104-
#if defined(LPUART1_BASE)
110+
#elif defined(STM32G0xx)
111+
#if defined(LPUART2_BASE)
112+
#define USART3_IRQn USART3_4_5_6_LPUART1_IRQn
113+
#define USART3_IRQHandler USART3_4_5_6_LPUART1_IRQHandler
114+
#elif defined(LPUART1_BASE)
105115
#define USART3_IRQn USART3_4_LPUART1_IRQn
106116
#define USART3_IRQHandler USART3_4_LPUART1_IRQHandler
107117
#else
108118
#define USART3_IRQn USART3_4_IRQn
109119
#define USART3_IRQHandler USART3_4_IRQHandler
110120
#endif
111-
#endif /* STM32G0xx */
121+
#endif /* STM32F0xx */
112122
#endif
113123

114124
#if defined(USART4_BASE) && !defined(USART4_IRQn)
@@ -123,15 +133,15 @@ struct serial_s {
123133
#endif /* STM32F091xC || STM32F098xx */
124134
#elif defined(STM32L0xx)
125135
#define USART4_IRQn USART4_5_IRQn
126-
#endif /* STM32F0xx */
127-
#if defined(STM32G0xx)
128-
#if defined(LPUART1_BASE)
136+
#elif defined(STM32G0xx)
137+
#if defined(LPUART2_BASE)
138+
#define USART4_IRQn USART3_4_5_6_LPUART1_IRQn
139+
#elif defined(LPUART1_BASE)
129140
#define USART4_IRQn USART3_4_LPUART1_IRQn
130141
#else
131142
#define USART4_IRQn USART3_4_IRQn
132143
#endif
133144
#endif /* STM32G0xx */
134-
135145
#endif
136146

137147
#if defined(USART5_BASE) && !defined(USART5_IRQn)
@@ -142,40 +152,63 @@ struct serial_s {
142152
#elif defined(STM32F030xC)
143153
#define USART5_IRQn USART3_6_IRQn
144154
#endif /* STM32F091xC || STM32F098xx */
155+
#elif defined(STM32G0xx)
156+
#if defined(LPUART2_BASE)
157+
#define USART5_IRQn USART3_4_5_6_LPUART1_IRQn
158+
#endif
145159
#elif defined(STM32L0xx)
146160
#define USART5_IRQn USART4_5_IRQn
147161
#endif /* STM32F0xx */
148162
#endif
149163

150-
#if defined (STM32F0xx)
151164
/* IRQHandler is mapped on USART3_IRQHandler for STM32F0xx */
152165
#if defined(USART6_BASE) && !defined(USART6_IRQn)
166+
#if defined (STM32F0xx)
153167
#if defined(STM32F091xC) || defined (STM32F098xx)
154168
#define USART6_IRQn USART3_8_IRQn
155169
#elif defined(STM32F030xC)
156170
#define USART6_IRQn USART3_6_IRQn
157171
#endif /* STM32F091xC || STM32F098xx */
172+
#elif defined(STM32G0xx)
173+
#if defined(LPUART2_BASE)
174+
#define USART6_IRQn USART3_4_5_6_LPUART1_IRQn
175+
#endif
176+
#endif /* STM32F0xx */
158177
#endif
159178

160179
#if defined(USART7_BASE) && !defined(USART7_IRQn)
180+
#if defined (STM32F0xx)
161181
#if defined(STM32F091xC) || defined (STM32F098xx)
162182
#define USART7_IRQn USART3_8_IRQn
163183
#endif /* STM32F091xC || STM32F098xx */
184+
#endif /* STM32F0xx */
164185
#endif
165186

166187
#if defined(USART8_BASE) && !defined(USART8_IRQn)
188+
#if defined (STM32F0xx)
167189
#if defined(STM32F091xC) || defined (STM32F098xx)
168190
#define USART8_IRQn USART3_8_IRQn
169191
#endif /* STM32F091xC || STM32F098xx */
170-
#endif
171192
#endif /* STM32F0xx */
193+
#endif
172194

173195
#if defined(LPUART1_BASE) && !defined(LPUART1_IRQn)
174-
#if defined(STM32G0xx) && defined(USART3_BASE)
196+
#if defined(STM32G0xx)
197+
#if defined(LPUART2_BASE)
198+
#define LPUART1_IRQn USART3_4_5_6_LPUART1_IRQn
199+
#elif defined(USART3_BASE)
175200
#define LPUART1_IRQn USART3_4_LPUART1_IRQn
201+
#endif
176202
#endif /* STM32G0xx */
177203
#endif
178204

205+
#if defined(LPUART2_BASE) && !defined(LPUART2_IRQn)
206+
#if defined(STM32G0xx)
207+
#if defined(LPUART2_BASE)
208+
#define LPUART2_IRQn USART2_LPUART2_IRQn
209+
#endif
210+
#endif /* STM32G0xx */
211+
#endif
179212

180213
/* Exported macro ------------------------------------------------------------*/
181214
/* Exported functions ------------------------------------------------------- */

Diff for: cores/arduino/stm32/usb/usbd_conf.h

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ extern "C" {
6767
#define USB_WKUP_IRQHandler USB_FS_WKUP_IRQHandler
6868
#endif
6969
#endif
70+
#elif defined(STM32G0xx)
71+
#define USB_IRQn USB_UCPD1_2_IRQn
72+
#define USB_IRQHandler USB_UCPD1_2_IRQHandler
7073
#elif defined(STM32L5xx)
7174
#define USB_IRQn USB_FS_IRQn
7275
#define USB_IRQHandler USB_FS_IRQHandler

0 commit comments

Comments
 (0)