Code: Select all
case USB_EP0_SENDING_STS:
/* All the above are invalid states in the IN phase.*/
osalDbgAssert(false, "EP0 state machine error");
Code: Select all
Thread #7 536882416 (usb_lld_pump : CURRENT) (Suspended : Signal : SIGINT:Interrupt)
chSysHalt() at chsys.c:182 0x802ba42
_usb_ep0out() at usb.c:950 0x802ba42
usb_lld_serve_interrupt() at usb_lld.c:605 0x8025558
Vector14C() at usb_lld.c:654 0x8025558
<signal handler called>() at 0xfffffffd
0x55555554
Modified usb_lld.c:
Code: Select all
/**
* @brief OTG shared ISR.
*
* @param[in] usbp pointer to the @p USBDriver object
*
* @notapi
*/
static void usb_lld_serve_interrupt(USBDriver *usbp) {
stm32_otg_t *otgp = usbp->otg;
uint32_t sts, src;
sts = otgp->GINTSTS;
sts &= otgp->GINTMSK;
otgp->GINTSTS = sts;
/* Reset interrupt handling.*/
if (sts & GINTSTS_USBRST) {
/* Resetting pending operations.*/
usbp->txpending = 0;
/* Default reset action.*/
_usb_reset(usbp);
/* Preventing execution of more handlers, the core has been reset.*/
return;
}
/* Wake-up handling.*/
if (sts & GINTSTS_WKUPINT) {
/* If clocks are gated off, turn them back on (may be the case if
coming out of suspend mode).*/
if (otgp->PCGCCTL & (PCGCCTL_STPPCLK | PCGCCTL_GATEHCLK)) {
/* Set to zero to un-gate the USB core clocks.*/
otgp->PCGCCTL &= ~(PCGCCTL_STPPCLK | PCGCCTL_GATEHCLK);
}
/* Clear the Remote Wake-up Signaling.*/
otgp->DCTL |= DCTL_RWUSIG;
_usb_wakeup(usbp);
}
/* Suspend handling.*/
if (sts & GINTSTS_USBSUSP) {
/* Resetting pending operations.*/
usbp->txpending = 0;
/* Default suspend action.*/
_usb_suspend(usbp);
}
/* Enumeration done.*/
if (sts & GINTSTS_ENUMDNE) {
/* Full or High speed timing selection.*/
if ((otgp->DSTS & DSTS_ENUMSPD_MASK) == DSTS_ENUMSPD_HS_480) {
otgp->GUSBCFG = (otgp->GUSBCFG & ~(GUSBCFG_TRDT_MASK)) |
GUSBCFG_TRDT(TRDT_VALUE_HS);
}
else {
otgp->GUSBCFG = (otgp->GUSBCFG & ~(GUSBCFG_TRDT_MASK)) |
GUSBCFG_TRDT(TRDT_VALUE_FS);
}
}
/* SOF interrupt handling.*/
if (sts & GINTSTS_SOF) {
_usb_isr_invoke_sof_cb(usbp);
}
/* Isochronous IN failed handling */
if (sts & GINTSTS_IISOIXFR) {
otg_isoc_in_failed_handler(usbp);
}
/* Isochronous OUT failed handling */
if (sts & GINTSTS_IISOOXFR) {
otg_isoc_out_failed_handler(usbp);
}
/* RX FIFO not empty handling.*/
if (sts & GINTSTS_RXFLVL) {
/* The interrupt is masked while the thread has control or it would
be triggered again.*/
osalSysLockFromISR();
otgp->GINTMSK &= ~GINTMSK_RXFLVLM;
osalThreadResumeI(&usbp->wait, MSG_OK);
osalSysUnlockFromISR();
}
/* IN/OUT endpoints event handling.*/
src = otgp->DAINT;
if (sts & GINTSTS_OEPINT) {
if (src & (1 << 16))
otg_epout_handler(usbp, 0);
if (src & (1 << 17))
otg_epout_handler(usbp, 1);
if (src & (1 << 18))
otg_epout_handler(usbp, 2);
if (src & (1 << 19))
otg_epout_handler(usbp, 3);
#if STM32_USB_USE_OTG2
if (src & (1 << 20))
otg_epout_handler(usbp, 4);
if (src & (1 << 21))
otg_epout_handler(usbp, 5);
#endif
}
if (sts & GINTSTS_IEPINT) {
if (src & (1 << 0))
otg_epin_handler(usbp, 0);
if (src & (1 << 1))
otg_epin_handler(usbp, 1);
if (src & (1 << 2))
otg_epin_handler(usbp, 2);
if (src & (1 << 3))
otg_epin_handler(usbp, 3);
#if STM32_USB_USE_OTG2
if (src & (1 << 4))
otg_epin_handler(usbp, 4);
if (src & (1 << 5))
otg_epin_handler(usbp, 5);
#endif
}
}
Cheers
Vinz