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

This commit is contained in:
Giovanni Di Sirio 2015-11-27 09:01:57 +00:00
parent ec59801695
commit be48aa8f69
1 changed files with 128 additions and 108 deletions

View File

@ -282,85 +282,17 @@ static void usb_packet_write_from_queue(stm32_usb_descriptor_t *udp,
osalSysRestoreStatusX(sts);
}
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
#if STM32_USB_USE_USB1 || defined(__DOXYGEN__)
#if STM32_USB1_HP_NUMBER != STM32_USB1_LP_NUMBER
/**
* @brief USB high priority interrupt handler.
* @brief Common ISR code, serves the EP-related interrupts.
*
* @isr
*/
OSAL_IRQ_HANDLER(STM32_USB1_HP_HANDLER) {
OSAL_IRQ_PROLOGUE();
OSAL_IRQ_EPILOGUE();
}
#endif /* STM32_USB1_LP_NUMBER != STM32_USB1_HP_NUMBER */
/**
* @brief USB low priority interrupt handler.
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
*
* @isr
* @notapi
*/
OSAL_IRQ_HANDLER(STM32_USB1_LP_HANDLER) {
uint32_t istr;
USBDriver *usbp = &USBD1;
OSAL_IRQ_PROLOGUE();
istr = STM32_USB->ISTR;
/* USB bus reset condition handling.*/
if (istr & ISTR_RESET) {
STM32_USB->ISTR = ~ISTR_RESET;
_usb_reset(usbp);
}
/* USB bus SUSPEND condition handling.*/
if (istr & ISTR_SUSP) {
STM32_USB->CNTR |= CNTR_FSUSP;
#if STM32_USB_LOW_POWER_ON_SUSPEND
STM32_USB->CNTR |= CNTR_LP_MODE;
#endif
STM32_USB->ISTR = ~ISTR_SUSP;
_usb_suspend(usbp);
}
/* USB bus WAKEUP condition handling.*/
if (istr & ISTR_WKUP) {
uint32_t fnr = STM32_USB->FNR;
if (!(fnr & FNR_RXDP)) {
STM32_USB->CNTR &= ~CNTR_FSUSP;
_usb_wakeup(usbp);
}
#if STM32_USB_LOW_POWER_ON_SUSPEND
else {
/* Just noise, going back in SUSPEND mode, reference manual 22.4.5,
table 169.*/
STM32_USB->CNTR |= CNTR_LP_MODE;
}
#endif
STM32_USB->ISTR = ~ISTR_WKUP;
}
/* SOF handling.*/
if (istr & ISTR_SOF) {
_usb_isr_invoke_sof_cb(usbp);
STM32_USB->ISTR = ~ISTR_SOF;
}
/* Endpoint events handling.*/
while (istr & ISTR_CTR) {
static void usb_serve_endpoints(USBDriver *usbp, uint32_t ep) {
size_t n;
uint32_t ep;
uint32_t epr = STM32_USB->EPR[ep = istr & ISTR_EP_ID_MASK];
uint32_t epr = STM32_USB->EPR[ep];
const USBEndpointConfig *epcp = usbp->epc[ep];
if (epr & EPR_CTR_TX) {
@ -466,6 +398,94 @@ OSAL_IRQ_HANDLER(STM32_USB1_LP_HANDLER) {
}
}
}
}
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
#if STM32_USB_USE_USB1 || defined(__DOXYGEN__)
#if STM32_USB1_HP_NUMBER != STM32_USB1_LP_NUMBER
/**
* @brief USB high priority interrupt handler.
*
* @isr
*/
OSAL_IRQ_HANDLER(STM32_USB1_HP_HANDLER) {
uint32_t istr;
USBDriver *usbp = &USBD1;
OSAL_IRQ_PROLOGUE();
/* Endpoint events handling.*/
istr = STM32_USB->ISTR;
while (istr & ISTR_CTR) {
usb_serve_endpoints(usbp, istr & ISTR_EP_ID_MASK);
istr = STM32_USB->ISTR;
}
OSAL_IRQ_EPILOGUE();
}
#endif /* STM32_USB1_LP_NUMBER != STM32_USB1_HP_NUMBER */
/**
* @brief USB low priority interrupt handler.
*
* @isr
*/
OSAL_IRQ_HANDLER(STM32_USB1_LP_HANDLER) {
uint32_t istr;
USBDriver *usbp = &USBD1;
OSAL_IRQ_PROLOGUE();
istr = STM32_USB->ISTR;
/* USB bus reset condition handling.*/
if (istr & ISTR_RESET) {
STM32_USB->ISTR = ~ISTR_RESET;
_usb_reset(usbp);
}
/* USB bus SUSPEND condition handling.*/
if (istr & ISTR_SUSP) {
STM32_USB->CNTR |= CNTR_FSUSP;
#if STM32_USB_LOW_POWER_ON_SUSPEND
STM32_USB->CNTR |= CNTR_LP_MODE;
#endif
STM32_USB->ISTR = ~ISTR_SUSP;
_usb_suspend(usbp);
}
/* USB bus WAKEUP condition handling.*/
if (istr & ISTR_WKUP) {
uint32_t fnr = STM32_USB->FNR;
if (!(fnr & FNR_RXDP)) {
STM32_USB->CNTR &= ~CNTR_FSUSP;
_usb_wakeup(usbp);
}
#if STM32_USB_LOW_POWER_ON_SUSPEND
else {
/* Just noise, going back in SUSPEND mode, reference manual 22.4.5,
table 169.*/
STM32_USB->CNTR |= CNTR_LP_MODE;
}
#endif
STM32_USB->ISTR = ~ISTR_WKUP;
}
/* SOF handling.*/
if (istr & ISTR_SOF) {
_usb_isr_invoke_sof_cb(usbp);
STM32_USB->ISTR = ~ISTR_SOF;
}
/* Endpoint events handling.*/
while (istr & ISTR_CTR) {
usb_serve_endpoints(usbp, istr & ISTR_EP_ID_MASK);
istr = STM32_USB->ISTR;
}