mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 11:10:14 +01:00
stm32/usbd_conf: Clean up USBD hardware initialization functions.
Break the FS and HS initialization routines out into separate functions, and call them as necessary from the TinyUSB or STM USB helper functions. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -62,16 +62,8 @@ PCD_HandleTypeDef pcd_hs_handle;
|
|||||||
#define OTG_HS_IRQn USB1_OTG_HS_IRQn
|
#define OTG_HS_IRQn USB1_OTG_HS_IRQn
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MICROPY_HW_TINYUSB_STACK
|
#if MICROPY_HW_USB_FS
|
||||||
void pyb_usbd_init(void)
|
static void mp_usbd_ll_init_fs(void) {
|
||||||
#else
|
|
||||||
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#if MICROPY_HW_USB_FS
|
|
||||||
#if MICROPY_HW_STM_USB_STACK
|
|
||||||
if (hpcd->Instance == USB_OTG_FS)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// Configure USB GPIO's.
|
// Configure USB GPIO's.
|
||||||
|
|
||||||
@@ -192,17 +184,12 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if MICROPY_HW_STM_USB_STACK
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
#endif // MICROPY_HW_USB_FS
|
||||||
|
|
||||||
#if MICROPY_HW_USB_HS
|
#if MICROPY_HW_USB_HS
|
||||||
#if MICROPY_HW_STM_USB_STACK
|
static void mp_usbd_ll_init_hs(void) {
|
||||||
if (hpcd->Instance == USB_OTG_HS)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
#if MICROPY_HW_USB_HS_IN_FS
|
#if MICROPY_HW_USB_HS_IN_FS
|
||||||
|
|
||||||
@@ -342,10 +329,36 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
|
|||||||
NVIC_SetPriority(OTG_HS_IRQn, IRQ_PRI_OTG_HS);
|
NVIC_SetPriority(OTG_HS_IRQn, IRQ_PRI_OTG_HS);
|
||||||
HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
|
HAL_NVIC_EnableIRQ(OTG_HS_IRQn);
|
||||||
}
|
}
|
||||||
#endif // MICROPY_HW_USB_HS
|
}
|
||||||
|
#endif // MICROPY_HW_USB_HS
|
||||||
|
|
||||||
|
#if MICROPY_HW_TINYUSB_STACK
|
||||||
|
|
||||||
|
void pyb_usbd_init(void) {
|
||||||
|
#if MICROPY_HW_USB_FS
|
||||||
|
mp_usbd_ll_init_fs();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MICROPY_HW_USB_HS
|
||||||
|
mp_usbd_ll_init_hs();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MICROPY_HW_STM_USB_STACK
|
#elif MICROPY_HW_STM_USB_STACK
|
||||||
|
|
||||||
|
void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) {
|
||||||
|
#if MICROPY_HW_USB_FS
|
||||||
|
if (hpcd->Instance == USB_OTG_FS) {
|
||||||
|
mp_usbd_ll_init_fs();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if MICROPY_HW_USB_HS
|
||||||
|
if (hpcd->Instance == USB_OTG_HS) {
|
||||||
|
mp_usbd_ll_init_hs();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief DeInitializes the PCD MSP.
|
* @brief DeInitializes the PCD MSP.
|
||||||
|
|||||||
Reference in New Issue
Block a user