From 304e1a7f4fbac7e1ef19cf07744d3dd2abfe3aff Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 24 Jun 2012 07:51:31 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4344 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/platforms/STM32/USBv1/usb_lld.c | 18 ++++++++++++------ os/hal/platforms/STM32/USBv1/usb_lld.h | 10 ++++++++++ os/hal/platforms/STM32F1xx/stm32_isr.h | 9 +++++++++ os/hal/platforms/STM32L1xx/stm32_isr.h | 9 +++++++++ 4 files changed, 40 insertions(+), 6 deletions(-) diff --git a/os/hal/platforms/STM32/USBv1/usb_lld.c b/os/hal/platforms/STM32/USBv1/usb_lld.c index 7bccf4e4d..0b72c3a56 100644 --- a/os/hal/platforms/STM32/USBv1/usb_lld.c +++ b/os/hal/platforms/STM32/USBv1/usb_lld.c @@ -264,24 +264,30 @@ static void usb_packet_write_from_queue(stm32_usb_descriptor_t *udp, /*===========================================================================*/ #if STM32_USB_USE_USB1 || defined(__DOXYGEN__) +#if !defined(STM32_USB1_HP_HANDLER) +#error "STM32_USB1_HP_HANDLER not defined" +#endif /** * @brief USB high priority interrupt handler. * * @isr */ -CH_IRQ_HANDLER(Vector8C) { +CH_IRQ_HANDLER(STM32_USB1_HP_HANDLER) { CH_IRQ_PROLOGUE(); CH_IRQ_EPILOGUE(); } +#if !defined(STM32_USB1_LP_HANDLER) +#error "STM32_USB1_LP_HANDLER not defined" +#endif /** * @brief USB low priority interrupt handler. * * @isr */ -CH_IRQ_HANDLER(Vector90) { +CH_IRQ_HANDLER(STM32_USB1_LP_HANDLER) { uint32_t istr; size_t n; USBDriver *usbp = &USBD1; @@ -446,9 +452,9 @@ void usb_lld_start(USBDriver *usbp) { STM32_USB->CNTR = CNTR_FRES; /* Enabling the USB IRQ vectors, this also gives enough time to allow the transceiver power up (1uS).*/ - nvicEnableVector(19, + nvicEnableVector(STM32_USB1_HP_NUMBER, CORTEX_PRIORITY_MASK(STM32_USB_USB1_HP_IRQ_PRIORITY)); - nvicEnableVector(20, + nvicEnableVector(STM32_USB1_LP_NUMBER, CORTEX_PRIORITY_MASK(STM32_USB_USB1_LP_IRQ_PRIORITY)); /* Releases the USB reset.*/ STM32_USB->CNTR = 0; @@ -473,8 +479,8 @@ void usb_lld_stop(USBDriver *usbp) { if (usbp->state == USB_STOP) { #if STM32_USB_USE_USB1 if (&USBD1 == usbp) { - nvicDisableVector(19); - nvicDisableVector(20); + nvicDisableVector(STM32_USB1_HP_NUMBER); + nvicDisableVector(STM32_USB1_LP_NUMBER); STM32_USB->CNTR = CNTR_PDWN | CNTR_FRES; rccDisableUSB(FALSE); } diff --git a/os/hal/platforms/STM32/USBv1/usb_lld.h b/os/hal/platforms/STM32/USBv1/usb_lld.h index f8c2b32f5..82181b2f4 100644 --- a/os/hal/platforms/STM32/USBv1/usb_lld.h +++ b/os/hal/platforms/STM32/USBv1/usb_lld.h @@ -93,6 +93,16 @@ #error "USB driver activated but no USB peripheral assigned" #endif +#if STM32_USB_USE_USB1 && \ + !CORTEX_IS_VALID_KERNEL_PRIORITY(STM32_USB_USB1_HP_IRQ_PRIORITY) +#error "Invalid IRQ priority assigned to USB HP" +#endif + +#if STM32_USB_USE_USB1 && \ + !CORTEX_IS_VALID_KERNEL_PRIORITY(STM32_USB_USB1_LP_IRQ_PRIORITY) +#error "Invalid IRQ priority assigned to USB LP" +#endif + #if STM32_USBCLK != 48000000 #error "the USB driver requires a 48MHz clock" #endif diff --git a/os/hal/platforms/STM32F1xx/stm32_isr.h b/os/hal/platforms/STM32F1xx/stm32_isr.h index c8c5d7fde..d9e634f0a 100644 --- a/os/hal/platforms/STM32F1xx/stm32_isr.h +++ b/os/hal/platforms/STM32F1xx/stm32_isr.h @@ -129,6 +129,15 @@ #define STM32_USART3_NUMBER USART3_IRQn #define STM32_UART4_NUMBER UART4_IRQn #define STM32_UART5_NUMBER UART5_IRQn + +/* + * USB units. + */ +#define STM32_USB1_HP_HANDLER Vector8C +#define STM32_USB1_LP_HANDLER Vector90 + +#define STM32_USB1_HP_NUMBER USB_HP_CAN1_TX_IRQn +#define STM32_USB1_LP_NUMBER USB_LP_CAN1_RX0_IRQn /** @} */ /*===========================================================================*/ diff --git a/os/hal/platforms/STM32L1xx/stm32_isr.h b/os/hal/platforms/STM32L1xx/stm32_isr.h index c753f6d24..84405e367 100644 --- a/os/hal/platforms/STM32L1xx/stm32_isr.h +++ b/os/hal/platforms/STM32L1xx/stm32_isr.h @@ -58,6 +58,15 @@ #define STM32_USART1_NUMBER USART1_IRQn #define STM32_USART2_NUMBER USART2_IRQn #define STM32_USART3_NUMBER USART3_IRQn + +/* + * USB units. + */ +#define STM32_USB1_HP_HANDLER Vector8C +#define STM32_USB1_LP_HANDLER Vector90 + +#define STM32_USB1_HP_NUMBER USB_HP_IRQn +#define STM32_USB1_LP_NUMBER USB_LP_IRQn /** @} */ /*===========================================================================*/