Skip to content

Commit

Permalink
Merge pull request #1253 from fpistm/updateG0
Browse files Browse the repository at this point in the history
Update STM32G0 HAL and CMSIS drivers
  • Loading branch information
fpistm committed May 21, 2021
2 parents 4b8fd08 + 54213f4 commit 633606a
Show file tree
Hide file tree
Showing 215 changed files with 94,900 additions and 7,621 deletions.
29 changes: 0 additions & 29 deletions CI/utils/patch/HAL/G0/0001-G0-Fix-HAL-definition.patch

This file was deleted.

8 changes: 8 additions & 0 deletions boards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5771,6 +5771,14 @@ GenG4.menu.xusb.HS.build.usb_speed=-DUSE_USB_HS
GenG4.menu.xusb.HSFS=High Speed in Full Speed mode
GenG4.menu.xusb.HSFS.build.usb_speed=-DUSE_USB_HS -DUSE_USB_HS_IN_FS

GenG0.menu.usb.none=None
GenG0.menu.usb.CDCgen=CDC (generic 'Serial' supersede U(S)ART)
GenG0.menu.usb.CDCgen.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC
GenG0.menu.usb.CDC=CDC (no generic 'Serial')
GenG0.menu.usb.CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DDISABLE_GENERIC_SERIALUSB
GenG0.menu.usb.HID=HID (keyboard and mouse)
GenG0.menu.usb.HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE

GenH7.menu.usb.none=None
GenH7.menu.usb.CDCgen=CDC (generic 'Serial' supersede U(S)ART)
GenH7.menu.usb.CDCgen.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC
Expand Down
25 changes: 19 additions & 6 deletions cores/arduino/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#if defined(HAVE_HWSERIAL1) || defined(HAVE_HWSERIAL2) || defined(HAVE_HWSERIAL3) ||\
defined(HAVE_HWSERIAL4) || defined(HAVE_HWSERIAL5) || defined(HAVE_HWSERIAL6) ||\
defined(HAVE_HWSERIAL7) || defined(HAVE_HWSERIAL8) || defined(HAVE_HWSERIAL9) ||\
defined(HAVE_HWSERIAL10) || defined(HAVE_HWSERIALLP1)
defined(HAVE_HWSERIAL10) || defined(HAVE_HWSERIALLP1) || defined(HAVE_HWSERIALLP2)
// SerialEvent functions are weak, so when the user doesn't define them,
// the linker just sets their address to 0 (which is checked below).
#if defined(HAVE_HWSERIAL1)
Expand Down Expand Up @@ -107,6 +107,11 @@
HardwareSerial SerialLP1(LPUART1);
void serialEventLP1() __attribute__((weak));
#endif

#if defined(HAVE_HWSERIALLP2)
HardwareSerial SerialLP2(LPUART2);
void serialEventLP2() __attribute__((weak));
#endif
#endif // HAVE_HWSERIALx

// Constructors ////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -252,11 +257,19 @@ HardwareSerial::HardwareSerial(void *peripheral, HalfDuplexMode_t halfDuplex)
setTx(PIN_SERIALLP1_TX);
} else
#endif
// else get the pins of the first peripheral occurence in PinMap
{
_serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX);
_serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX);
}
#if defined(PIN_SERIALLP2_TX) && defined(LPUART2_BASE)
if (peripheral == LPUART2) {
#if defined(PIN_SERIALLP2_RX)
setRx(PIN_SERIALLP2_RX);
#endif
setTx(PIN_SERIALLP2_TX);
} else
#endif
// else get the pins of the first peripheral occurence in PinMap
{
_serial.pin_rx = pinmap_pin(peripheral, PinMap_UART_RX);
_serial.pin_tx = pinmap_pin(peripheral, PinMap_UART_TX);
}
if (halfDuplex == HALF_DUPLEX_ENABLED) {
_serial.pin_rx = NC;
}
Expand Down
4 changes: 3 additions & 1 deletion cores/arduino/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,7 @@ class HardwareSerial : public Stream {
#if defined(LPUART1)
extern HardwareSerial SerialLP1;
#endif

#if defined(LPUART2)
extern HardwareSerial SerialLP2;
#endif
#endif
5 changes: 5 additions & 0 deletions cores/arduino/HardwareTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,11 @@ extern "C" {
if (HardwareTimer_Handle[TIMER3_INDEX]) {
HAL_TIM_IRQHandler(&HardwareTimer_Handle[TIMER3_INDEX]->handle);
}
#if defined(STM32G0xx) && defined(TIM4_BASE)
if (HardwareTimer_Handle[TIMER4_INDEX]) {
HAL_TIM_IRQHandler(&HardwareTimer_Handle[TIMER4_INDEX]->handle);
}
#endif
}
#endif //TIM3_BASE

Expand Down
5 changes: 5 additions & 0 deletions cores/arduino/WSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ WEAK void serialEventRun(void)
serialEventLP1();
}
#endif
#if defined(HAVE_HWSERIALLP2)
if (serialEventLP2 && SerialLP2.available()) {
serialEventLP2();
}
#endif
#if defined(HAVE_SERIALUSB)
if (serialEventUSB && SerialUSB.available()) {
serialEventUSB();
Expand Down
14 changes: 14 additions & 0 deletions cores/arduino/WSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
#define Serial SerialLP1
#define serialEvent serialEventLP1
#endif
#elif SERIAL_UART_INSTANCE == 102
#define ENABLE_HWSERIALLP2
#if !defined(Serial)
#define Serial SerialLP2
#define serialEvent serialEventLP2
#endif
#elif SERIAL_UART_INSTANCE == 1
#define ENABLE_HWSERIAL1
#if !defined(Serial)
Expand Down Expand Up @@ -118,6 +124,11 @@
#define HAVE_HWSERIALLP1
#endif
#endif
#if defined(ENABLE_HWSERIALLP2)
#if defined(LPUART2_BASE)
#define HAVE_HWSERIALLP2
#endif
#endif
#if defined(ENABLE_HWSERIAL1)
#if defined(USART1_BASE)
#define HAVE_HWSERIAL1
Expand Down Expand Up @@ -202,6 +213,9 @@
#if defined(HAVE_HWSERIALLP1)
extern void serialEventLP1(void) __attribute__((weak));
#endif
#if defined(HAVE_HWSERIALLP2)
extern void serialEventLP2(void) __attribute__((weak));
#endif
#endif /* HAL_UART_MODULE_ENABLED && !HAL_UART_MODULE_ONLY */

extern void serialEventRun(void);
Expand Down
3 changes: 3 additions & 0 deletions cores/arduino/stm32/LL/stm32yyxx_ll_crs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#ifdef STM32F0xx
#include "stm32f0xx_ll_crs.h"
#endif
#ifdef STM32G0xx
#include "stm32g0xx_ll_crs.h"
#endif
#ifdef STM32G4xx
#include "stm32g4xx_ll_crs.h"
#endif
Expand Down
3 changes: 3 additions & 0 deletions cores/arduino/stm32/LL/stm32yyxx_ll_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
#ifdef STM32F7xx
#include "stm32f7xx_ll_usb.h"
#endif
#ifdef STM32G0xx
#include "stm32g0xx_ll_usb.h"
#endif
#ifdef STM32G4xx
#include "stm32g4xx_ll_usb.h"
#endif
Expand Down
6 changes: 6 additions & 0 deletions cores/arduino/stm32/stm32_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@
#define CAN1 CAN
#endif

/* STM32G0xx defined USB_DRD_FS */
#if !defined(USB ) && defined(USB_DRD_FS)
#define USB USB_DRD_FS
#define PinMap_USB PinMap_USB_DRD_FS
#endif

/**
* Libc porting layers
*/
Expand Down
12 changes: 12 additions & 0 deletions cores/arduino/stm32/stm32_def_build.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,24 @@
#define CMSIS_STARTUP_FILE "startup_stm32g031xx.s"
#elif defined(STM32G041xx)
#define CMSIS_STARTUP_FILE "startup_stm32g041xx.s"
#elif defined(STM32G050xx)
#define CMSIS_STARTUP_FILE "startup_stm32g050xx.s"
#elif defined(STM32G051xx)
#define CMSIS_STARTUP_FILE "startup_stm32g051xx.s"
#elif defined(STM32G061xx)
#define CMSIS_STARTUP_FILE "startup_stm32g061xx.s"
#elif defined(STM32G070xx)
#define CMSIS_STARTUP_FILE "startup_stm32g070xx.s"
#elif defined(STM32G071xx)
#define CMSIS_STARTUP_FILE "startup_stm32g071xx.s"
#elif defined(STM32G081xx)
#define CMSIS_STARTUP_FILE "startup_stm32g081xx.s"
#elif defined(STM32G0B0xx)
#define CMSIS_STARTUP_FILE "startup_stm32g0b0xx.s"
#elif defined(STM32G0B1xx)
#define CMSIS_STARTUP_FILE "startup_stm32g0b1xx.s"
#elif defined(STM32G0C1xx)
#define CMSIS_STARTUP_FILE "startup_stm32g0c1xx.s"
#elif defined(STM32G431xx)
#define CMSIS_STARTUP_FILE "startup_stm32g431xx.s"
#elif defined(STM32G441xx)
Expand Down
19 changes: 19 additions & 0 deletions cores/arduino/stm32/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ extern "C" {
#endif
#endif

#if defined(TIM3_BASE) && !defined(TIM3_IRQn)
#if defined(STM32G0xx) && defined(TIM4_BASE)
#define TIM3_IRQn TIM3_TIM4_IRQn
#define TIM3_IRQHandler TIM3_TIM4_IRQHandler
#endif
#endif

#if defined(TIM4_BASE) && !defined(TIM4_IRQn)
#if defined(STM32G0xx)
#define TIM4_IRQn TIM3_TIM4_IRQn
#endif
#endif

#if defined(TIM6_BASE) && !defined(TIM6_IRQn)
#if defined(DAC_BASE) || defined(DAC1_BASE)
#if defined(STM32G0xx)
Expand Down Expand Up @@ -147,13 +160,19 @@ extern "C" {
defined(STM32WBxx)
#define TIM16_IRQn TIM1_UP_TIM16_IRQn
//TIM16_IRQHandler is mapped on TIM1_IRQHandler when TIM16_IRQn is not defined
#elif defined(STM32G0xx) && defined(FDCAN1_BASE)
#define TIM16_IRQn TIM16_FDCAN_IT0_IRQn
#define TIM16_IRQHandler TIM16_FDCAN_IT0_IRQHandler
#endif
#endif
#if defined(TIM17_BASE) && !defined(TIM17_IRQn)
#if defined(STM32F1xx) || defined(STM32F3xx) || defined(STM32G4xx) || defined(STM32L4xx) || \
defined(STM32WBxx)
#define TIM17_IRQn TIM1_TRG_COM_TIM17_IRQn
#define TIM17_IRQHandler TIM1_TRG_COM_TIM17_IRQHandler
#elif defined(STM32G0xx) && defined(FDCAN1_BASE)
#define TIM17_IRQn TIM17_FDCAN_IT1_IRQn
#define TIM17_IRQHandler TIM17_FDCAN_IT1_IRQHandler
#endif
#endif
#if defined(TIM18_BASE) && !defined(TIM18_IRQn)
Expand Down
57 changes: 45 additions & 12 deletions cores/arduino/stm32/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ struct serial_s {
/* Exported constants --------------------------------------------------------*/
#define TX_TIMEOUT 1000

#if defined(USART2_BASE) && !defined(USART2_IRQn)
#if defined(STM32G0xx)
#if defined(LPUART2_BASE)
#define USART2_IRQn USART2_LPUART2_IRQn
#define USART2_IRQHandler USART2_LPUART2_IRQHandler
#endif
#endif /* STM32G0xx */
#endif

#if defined(USART3_BASE) && !defined(USART3_IRQn)
#if defined(STM32F0xx)
#if defined(STM32F091xC) || defined (STM32F098xx)
Expand All @@ -98,17 +107,18 @@ struct serial_s {
#define USART3_IRQn USART3_4_IRQn
#define USART3_IRQHandler USART3_4_IRQHandler
#endif /* STM32F091xC || STM32F098xx */
#endif /* STM32F0xx */

#if defined(STM32G0xx)
#if defined(LPUART1_BASE)
#elif defined(STM32G0xx)
#if defined(LPUART2_BASE)
#define USART3_IRQn USART3_4_5_6_LPUART1_IRQn
#define USART3_IRQHandler USART3_4_5_6_LPUART1_IRQHandler
#elif defined(LPUART1_BASE)
#define USART3_IRQn USART3_4_LPUART1_IRQn
#define USART3_IRQHandler USART3_4_LPUART1_IRQHandler
#else
#define USART3_IRQn USART3_4_IRQn
#define USART3_IRQHandler USART3_4_IRQHandler
#endif
#endif /* STM32G0xx */
#endif /* STM32F0xx */
#endif

#if defined(USART4_BASE) && !defined(USART4_IRQn)
Expand All @@ -123,15 +133,15 @@ struct serial_s {
#endif /* STM32F091xC || STM32F098xx */
#elif defined(STM32L0xx)
#define USART4_IRQn USART4_5_IRQn
#endif /* STM32F0xx */
#if defined(STM32G0xx)
#if defined(LPUART1_BASE)
#elif defined(STM32G0xx)
#if defined(LPUART2_BASE)
#define USART4_IRQn USART3_4_5_6_LPUART1_IRQn
#elif defined(LPUART1_BASE)
#define USART4_IRQn USART3_4_LPUART1_IRQn
#else
#define USART4_IRQn USART3_4_IRQn
#endif
#endif /* STM32G0xx */

#endif

#if defined(USART5_BASE) && !defined(USART5_IRQn)
Expand All @@ -142,40 +152,63 @@ struct serial_s {
#elif defined(STM32F030xC)
#define USART5_IRQn USART3_6_IRQn
#endif /* STM32F091xC || STM32F098xx */
#elif defined(STM32G0xx)
#if defined(LPUART2_BASE)
#define USART5_IRQn USART3_4_5_6_LPUART1_IRQn
#endif
#elif defined(STM32L0xx)
#define USART5_IRQn USART4_5_IRQn
#endif /* STM32F0xx */
#endif

#if defined (STM32F0xx)
/* IRQHandler is mapped on USART3_IRQHandler for STM32F0xx */
#if defined(USART6_BASE) && !defined(USART6_IRQn)
#if defined (STM32F0xx)
#if defined(STM32F091xC) || defined (STM32F098xx)
#define USART6_IRQn USART3_8_IRQn
#elif defined(STM32F030xC)
#define USART6_IRQn USART3_6_IRQn
#endif /* STM32F091xC || STM32F098xx */
#elif defined(STM32G0xx)
#if defined(LPUART2_BASE)
#define USART6_IRQn USART3_4_5_6_LPUART1_IRQn
#endif
#endif /* STM32F0xx */
#endif

#if defined(USART7_BASE) && !defined(USART7_IRQn)
#if defined (STM32F0xx)
#if defined(STM32F091xC) || defined (STM32F098xx)
#define USART7_IRQn USART3_8_IRQn
#endif /* STM32F091xC || STM32F098xx */
#endif /* STM32F0xx */
#endif

#if defined(USART8_BASE) && !defined(USART8_IRQn)
#if defined (STM32F0xx)
#if defined(STM32F091xC) || defined (STM32F098xx)
#define USART8_IRQn USART3_8_IRQn
#endif /* STM32F091xC || STM32F098xx */
#endif
#endif /* STM32F0xx */
#endif

#if defined(LPUART1_BASE) && !defined(LPUART1_IRQn)
#if defined(STM32G0xx) && defined(USART3_BASE)
#if defined(STM32G0xx)
#if defined(LPUART2_BASE)
#define LPUART1_IRQn USART3_4_5_6_LPUART1_IRQn
#elif defined(USART3_BASE)
#define LPUART1_IRQn USART3_4_LPUART1_IRQn
#endif
#endif /* STM32G0xx */
#endif

#if defined(LPUART2_BASE) && !defined(LPUART2_IRQn)
#if defined(STM32G0xx)
#if defined(LPUART2_BASE)
#define LPUART2_IRQn USART2_LPUART2_IRQn
#endif
#endif /* STM32G0xx */
#endif

/* Exported macro ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
Expand Down
3 changes: 3 additions & 0 deletions cores/arduino/stm32/usb/usbd_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ extern "C" {
#define USB_WKUP_IRQHandler USB_FS_WKUP_IRQHandler
#endif
#endif
#elif defined(STM32G0xx)
#define USB_IRQn USB_UCPD1_2_IRQn
#define USB_IRQHandler USB_UCPD1_2_IRQHandler
#elif defined(STM32L5xx)
#define USB_IRQn USB_FS_IRQn
#define USB_IRQHandler USB_FS_IRQHandler
Expand Down
Loading

0 comments on commit 633606a

Please sign in to comment.