git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4344 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2012-06-24 07:51:31 +00:00
parent ca6ab337fe
commit 304e1a7f4f
4 changed files with 40 additions and 6 deletions

View File

@ -264,24 +264,30 @@ static void usb_packet_write_from_queue(stm32_usb_descriptor_t *udp,
/*===========================================================================*/ /*===========================================================================*/
#if STM32_USB_USE_USB1 || defined(__DOXYGEN__) #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. * @brief USB high priority interrupt handler.
* *
* @isr * @isr
*/ */
CH_IRQ_HANDLER(Vector8C) { CH_IRQ_HANDLER(STM32_USB1_HP_HANDLER) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();
CH_IRQ_EPILOGUE(); CH_IRQ_EPILOGUE();
} }
#if !defined(STM32_USB1_LP_HANDLER)
#error "STM32_USB1_LP_HANDLER not defined"
#endif
/** /**
* @brief USB low priority interrupt handler. * @brief USB low priority interrupt handler.
* *
* @isr * @isr
*/ */
CH_IRQ_HANDLER(Vector90) { CH_IRQ_HANDLER(STM32_USB1_LP_HANDLER) {
uint32_t istr; uint32_t istr;
size_t n; size_t n;
USBDriver *usbp = &USBD1; USBDriver *usbp = &USBD1;
@ -446,9 +452,9 @@ void usb_lld_start(USBDriver *usbp) {
STM32_USB->CNTR = CNTR_FRES; STM32_USB->CNTR = CNTR_FRES;
/* Enabling the USB IRQ vectors, this also gives enough time to allow /* Enabling the USB IRQ vectors, this also gives enough time to allow
the transceiver power up (1uS).*/ the transceiver power up (1uS).*/
nvicEnableVector(19, nvicEnableVector(STM32_USB1_HP_NUMBER,
CORTEX_PRIORITY_MASK(STM32_USB_USB1_HP_IRQ_PRIORITY)); 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)); CORTEX_PRIORITY_MASK(STM32_USB_USB1_LP_IRQ_PRIORITY));
/* Releases the USB reset.*/ /* Releases the USB reset.*/
STM32_USB->CNTR = 0; STM32_USB->CNTR = 0;
@ -473,8 +479,8 @@ void usb_lld_stop(USBDriver *usbp) {
if (usbp->state == USB_STOP) { if (usbp->state == USB_STOP) {
#if STM32_USB_USE_USB1 #if STM32_USB_USE_USB1
if (&USBD1 == usbp) { if (&USBD1 == usbp) {
nvicDisableVector(19); nvicDisableVector(STM32_USB1_HP_NUMBER);
nvicDisableVector(20); nvicDisableVector(STM32_USB1_LP_NUMBER);
STM32_USB->CNTR = CNTR_PDWN | CNTR_FRES; STM32_USB->CNTR = CNTR_PDWN | CNTR_FRES;
rccDisableUSB(FALSE); rccDisableUSB(FALSE);
} }

View File

@ -93,6 +93,16 @@
#error "USB driver activated but no USB peripheral assigned" #error "USB driver activated but no USB peripheral assigned"
#endif #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 #if STM32_USBCLK != 48000000
#error "the USB driver requires a 48MHz clock" #error "the USB driver requires a 48MHz clock"
#endif #endif

View File

@ -129,6 +129,15 @@
#define STM32_USART3_NUMBER USART3_IRQn #define STM32_USART3_NUMBER USART3_IRQn
#define STM32_UART4_NUMBER UART4_IRQn #define STM32_UART4_NUMBER UART4_IRQn
#define STM32_UART5_NUMBER UART5_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
/** @} */ /** @} */
/*===========================================================================*/ /*===========================================================================*/

View File

@ -58,6 +58,15 @@
#define STM32_USART1_NUMBER USART1_IRQn #define STM32_USART1_NUMBER USART1_IRQn
#define STM32_USART2_NUMBER USART2_IRQn #define STM32_USART2_NUMBER USART2_IRQn
#define STM32_USART3_NUMBER USART3_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
/** @} */ /** @} */
/*===========================================================================*/ /*===========================================================================*/