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

CI/utils/patch/HAL/G0/0001-G0-Fix-HAL-definition.patch

Lines changed: 0 additions & 29 deletions
This file was deleted.

boards.txt

Lines changed: 8 additions & 0 deletions
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

cores/arduino/HardwareSerial.cpp

Lines changed: 19 additions & 6 deletions
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
}

cores/arduino/HardwareSerial.h

Lines changed: 3 additions & 1 deletion
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

cores/arduino/HardwareTimer.cpp

Lines changed: 5 additions & 0 deletions
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

cores/arduino/WSerial.cpp

Lines changed: 5 additions & 0 deletions
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();

cores/arduino/WSerial.h

Lines changed: 14 additions & 0 deletions
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);

cores/arduino/stm32/LL/stm32yyxx_ll_crs.h

Lines changed: 3 additions & 0 deletions
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

cores/arduino/stm32/LL/stm32yyxx_ll_usb.h

Lines changed: 3 additions & 0 deletions
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

cores/arduino/stm32/stm32_def.h

Lines changed: 6 additions & 0 deletions
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
*/

0 commit comments

Comments
 (0)