aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-12-27 11:12:09 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-12-27 11:12:09 +0000
commitd93fdcd424c049078009119940d0042bb229ed38 (patch)
tree52201084180b40246ced4918e47936bbaaff0d97 /os/hal/ports/STM32/LLD
parentef8ef298b95d0ea9c8807b36b7ae939f2dbab510 (diff)
downloadChibiOS-d93fdcd424c049078009119940d0042bb229ed38.tar.gz
ChibiOS-d93fdcd424c049078009119940d0042bb229ed38.tar.bz2
ChibiOS-d93fdcd424c049078009119940d0042bb229ed38.zip
Fixed stability problems in OTGv1.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8651 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/STM32/LLD')
-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);