Skip to content

Commit adc9a43

Browse files
committed
USB: review IRQn and IRQHandler across series
Fix stm32duino#1283 Signed-off-by: Frederic Pillon <[email protected]>
1 parent 2e9eeab commit adc9a43

File tree

2 files changed

+27
-38
lines changed

2 files changed

+27
-38
lines changed

cores/arduino/stm32/usb/usbd_conf.c

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,22 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
7373
/* Enable USB FS Clock */
7474
__HAL_RCC_USB_CLK_ENABLE();
7575

76-
#if defined (USE_USB_INTERRUPT_REMAPPED)
77-
/*USB interrupt remapping enable */
76+
#if defined(SYSCFG_CFGR1_USB_IT_RMP) && defined(USE_USB_INTERRUPT_REMAPPED)
77+
/* USB interrupt remapping enable */
7878
__HAL_REMAPINTERRUPT_USB_ENABLE();
7979
#endif
8080

81-
#if defined(STM32G4xx) || defined(STM32WBxx)
81+
#if defined(USB_H_IRQn)
82+
/* Set USB High priority Interrupt priority */
8283
HAL_NVIC_SetPriority(USB_HP_IRQn, USBD_IRQ_PRIO, USBD_IRQ_SUBPRIO);
84+
/* Enable USB High priority Interrupt */
8385
HAL_NVIC_EnableIRQ(USB_HP_IRQn);
84-
HAL_NVIC_SetPriority(USB_LP_IRQn, USBD_IRQ_PRIO, USBD_IRQ_SUBPRIO);
85-
HAL_NVIC_EnableIRQ(USB_LP_IRQn);
86-
#else
87-
/* Set USB FS Interrupt priority */
86+
#endif
87+
/* Set USB Interrupt priority */
8888
HAL_NVIC_SetPriority(USB_IRQn, USBD_IRQ_PRIO, USBD_IRQ_SUBPRIO);
8989

90-
/* Enable USB FS Interrupt */
90+
/* Enable USB Interrupt */
9191
HAL_NVIC_EnableIRQ(USB_IRQn);
92-
#endif /* STM32WBxx */
9392

9493
if (hpcd->Init.low_power_enable == 1) {
9594
/* Enable EXTI for USB wakeup */
@@ -163,7 +162,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd)
163162
/* Enable USB HS Clocks */
164163
__HAL_RCC_USB_OTG_HS_CLK_ENABLE();
165164

166-
/* Set USBHS Interrupt priority */
165+
/* Set USB HS Interrupt priority */
167166
HAL_NVIC_SetPriority(OTG_HS_IRQn, USBD_IRQ_PRIO, USBD_IRQ_SUBPRIO);
168167

169168
/* Enable USB HS Interrupt */
@@ -387,27 +386,19 @@ void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd)
387386
HAL_PCD_IRQHandler(&g_hpcd);
388387
}
389388

390-
#if defined(STM32WBxx)
389+
#if defined(USB_H_IRQn)
391390
/**
392391
* @brief This function handles USB high priority interrupt.
393392
* @param None
394393
* @retval None
395394
*/
396-
void USB_HP_IRQHandler(void)
395+
void USB_H_IRQHandler(void)
397396
{
398397
HAL_PCD_IRQHandler(&g_hpcd);
399398
}
399+
#endif /* USB_H_IRQn */
400400

401401
/**
402-
* @brief This function handles USB low priority interrupt, USB wake-up interrupt through EXTI line 28.
403-
* @param None
404-
* @retval None
405-
*/
406-
void USB_LP_IRQHandler(void)
407-
{
408-
HAL_PCD_IRQHandler(&g_hpcd);
409-
}
410-
#else
411402
/**
412403
* @brief This function handles USB OTG FS Wakeup IRQ Handler.
413404
* @param None
@@ -442,7 +433,7 @@ void USB_LP_IRQHandler(void)
442433
__HAL_USB_WAKEUP_EXTI_CLEAR_FLAG();
443434
#endif
444435
}
445-
#endif
436+
446437
/*******************************************************************************
447438
LL Driver Interface (USB Device Library --> PCD)
448439
*******************************************************************************/

cores/arduino/stm32/usb/usbd_conf.h

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,22 @@ extern "C" {
4242

4343
#if defined(USB_BASE)
4444

45-
#if defined(STM32F1xx)
46-
#define USB_IRQn USB_LP_CAN1_RX0_IRQn
47-
#define USB_IRQHandler USB_LP_CAN1_RX0_IRQHandler
48-
#elif defined(STM32F3xx)
49-
/* ToDo: Check remap on USB_LP_IRQn */
50-
#ifndef USE_USB_INTERRUPT_REMAPPED
51-
#define USB_IRQn USB_LP_CAN_RX0_IRQn
52-
#define USB_IRQHandler USB_LP_CAN_RX0_IRQHandler
45+
#if defined(STM32F1xx) || defined(STM32F3xx) || defined(STM32G4xx) || \
46+
defined(STM32L1xx) || defined(STM32WBxx)
47+
#if defined(SYSCFG_CFGR1_USB_IT_RMP) && defined(USE_USB_INTERRUPT_REMAPPED)
48+
#define USB_IRQn USB_LP_CAN_RX0_IRQn
49+
#define USB_IRQHandler USB_LP_CAN_RX0_IRQHandler
50+
#define USB_H_IRQn USB_HP_CAN_TX_IRQn
51+
#define USB_H_IRQHandler USB_HP_CAN_TX_IRQHandler
5352
#else
54-
#define USB_IRQn USB_LP_IRQn
55-
#define USB_IRQHandler USB_LP_IRQHandler
56-
#endif /* USE_USB_INTERRUPT_REMAPPED */
57-
#elif defined(STM32L1xx)
58-
#define USB_IRQn USB_LP_IRQn
59-
#define USB_IRQHandler USB_LP_IRQHandler
53+
#define USB_IRQn USB_LP_IRQn
54+
#define USB_IRQHandler USB_LP_IRQHandler
55+
#define USB_H_IRQn USB_HP_IRQn
56+
#define USB_H_IRQHandler USB_HP_IRQHandler
57+
#endif
6058
#elif defined(STM32L5xx)
61-
#define USB_IRQn USB_FS_IRQn
62-
#define USB_IRQHandler USB_FS_IRQHandler
59+
#define USB_IRQn USB_FS_IRQn
60+
#define USB_IRQHandler USB_FS_IRQHandler
6361
#endif
6462

6563
#endif /* USB_BASE */

0 commit comments

Comments
 (0)