aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/ports/STM32/LLD/OTGv1/usb_lld.c')
-rw-r--r--os/hal/ports/STM32/LLD/OTGv1/usb_lld.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c
index 00ada1203..a4a784d2a 100644
--- a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c
+++ b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c
@@ -511,6 +511,19 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) {
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
@@ -529,13 +542,11 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) {
/* Suspend handling.*/
if (sts & GINTSTS_USBSUSP) {
- _usb_suspend(usbp);
- }
-
- /* Reset interrupt handling.*/
- if (sts & GINTSTS_USBRST) {
+ /* Resetting pending operations.*/
+ usbp->txpending = 0;
- _usb_reset(usbp);
+ /* Default suspend action.*/
+ _usb_suspend(usbp);
}
/* Enumeration done.*/
@@ -920,18 +931,18 @@ void usb_lld_reset(USBDriver *usbp) {
/* Flush the Tx FIFO.*/
otg_txfifo_flush(usbp, 0);
+ /* Endpoint interrupts all disabled and cleared.*/
+ otgp->DIEPEMPMSK = 0;
+ otgp->DAINTMSK = DAINTMSK_OEPM(0) | DAINTMSK_IEPM(0);
+
/* All endpoints in NAK mode, interrupts cleared.*/
for (i = 0; i <= usbp->otgparams->num_endpoints; i++) {
otgp->ie[i].DIEPCTL = DIEPCTL_SNAK;
otgp->oe[i].DOEPCTL = DOEPCTL_SNAK;
- otgp->ie[i].DIEPINT = 0xFF;
- otgp->oe[i].DOEPINT = 0xFF;
+ otgp->ie[i].DIEPINT = 0xFFFFFFFF;
+ otgp->oe[i].DOEPINT = 0xFFFFFFFF;
}
- /* Endpoint interrupts all disabled and cleared.*/
- otgp->DAINT = 0xFFFFFFFF;
- otgp->DAINTMSK = DAINTMSK_OEPM(0) | DAINTMSK_IEPM(0);
-
/* Resets the FIFO memory allocator.*/
otg_ram_reset(usbp);