stm32/usb: Fix USB support on STM32G4.

Also fix MAX_ENDPOINT definition for G0, which follows G4.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
Jim Mussared 2023-05-19 16:11:05 +10:00 committed by Damien George
parent 0000eb2724
commit f4b4d05e49
4 changed files with 6 additions and 6 deletions

View File

@ -559,7 +559,7 @@
#endif #endif
// Whether the USB peripheral is device-only, or multiple OTG // Whether the USB peripheral is device-only, or multiple OTG
#if defined(STM32L0) || defined(STM32L432xx) || defined(STM32WB) #if defined(STM32G4) || defined(STM32L0) || defined(STM32L432xx) || defined(STM32WB)
#define MICROPY_HW_USB_IS_MULTI_OTG (0) #define MICROPY_HW_USB_IS_MULTI_OTG (0)
#else #else
#define MICROPY_HW_USB_IS_MULTI_OTG (1) #define MICROPY_HW_USB_IS_MULTI_OTG (1)

View File

@ -312,7 +312,7 @@ void USB_IRQHandler(void) {
} }
#endif #endif
#elif defined(STM32WB) #elif defined(STM32G4) || defined(STM32WB)
#if MICROPY_HW_USB_FS #if MICROPY_HW_USB_FS
void USB_LP_IRQHandler(void) { void USB_LP_IRQHandler(void) {

View File

@ -59,7 +59,7 @@
#endif #endif
// Maximum number of endpoints (excluding EP0) // Maximum number of endpoints (excluding EP0)
#if defined(STM32L0) || defined(STM32WB) #if defined(STM32G0) || defined(STM32G4) || defined(STM32L0) || defined(STM32WB)
#define MAX_ENDPOINT(dev_id) (7) #define MAX_ENDPOINT(dev_id) (7)
#elif defined(STM32L4) #elif defined(STM32L4)
#define MAX_ENDPOINT(dev_id) (5) #define MAX_ENDPOINT(dev_id) (5)
@ -67,7 +67,7 @@
#define MAX_ENDPOINT(dev_id) ((dev_id) == USB_PHY_FS_ID ? 3 : 5) #define MAX_ENDPOINT(dev_id) ((dev_id) == USB_PHY_FS_ID ? 3 : 5)
#elif defined(STM32F7) #elif defined(STM32F7)
#define MAX_ENDPOINT(dev_id) ((dev_id) == USB_PHY_FS_ID ? 5 : 8) #define MAX_ENDPOINT(dev_id) ((dev_id) == USB_PHY_FS_ID ? 5 : 8)
#elif defined(STM32G0) || defined(STM32H7) #elif defined(STM32H7)
#define MAX_ENDPOINT(dev_id) (8) #define MAX_ENDPOINT(dev_id) (8)
#endif #endif

View File

@ -67,7 +67,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) {
if (hpcd->Instance == USB_OTG_FS) { if (hpcd->Instance == USB_OTG_FS) {
// Configure USB GPIO's. // Configure USB GPIO's.
#if defined(STM32G0) #if defined(STM32G0) || defined(STM32G4)
// These MCUs don't have an alternate function for USB but rather require // These MCUs don't have an alternate function for USB but rather require
// the pins to be disconnected from all peripherals, ie put in analog mode. // the pins to be disconnected from all peripherals, ie put in analog mode.
@ -146,7 +146,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) {
#elif defined(STM32L432xx) #elif defined(STM32L432xx)
NVIC_SetPriority(USB_FS_IRQn, IRQ_PRI_OTG_FS); NVIC_SetPriority(USB_FS_IRQn, IRQ_PRI_OTG_FS);
HAL_NVIC_EnableIRQ(USB_FS_IRQn); HAL_NVIC_EnableIRQ(USB_FS_IRQn);
#elif defined(STM32WB) #elif defined(STM32G4) || defined(STM32WB)
NVIC_SetPriority(USB_LP_IRQn, IRQ_PRI_OTG_FS); NVIC_SetPriority(USB_LP_IRQn, IRQ_PRI_OTG_FS);
HAL_NVIC_EnableIRQ(USB_LP_IRQn); HAL_NVIC_EnableIRQ(USB_LP_IRQn);
#else #else