From 61d16a339ee3ff93fcae6bf3c07afe0977715341 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 28 Nov 2015 17:58:01 +0000 Subject: [PATCH] Fixed bug #674 (again). git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8542 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/LLD/OTGv1/usb_lld.c | 27 +++----------------------- testhal/STM32/STM32F7xx/USB_CDC/main.c | 5 +++++ 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c index 85be3e26f..ae944f77d 100644 --- a/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c +++ b/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c @@ -147,32 +147,11 @@ static void otg_disable_ep(USBDriver *usbp) { unsigned i; for (i = 0; i <= usbp->otgparams->num_endpoints; i++) { - /* Disable only if enabled because this sentence in the manual: - "The application must set this bit only if Endpoint Enable is - already set for this endpoint".*/ - if ((otgp->ie[i].DIEPCTL & DIEPCTL_EPENA) != 0) { - otgp->ie[i].DIEPCTL = DIEPCTL_EPDIS; - /* Wait for endpoint disable.*/ - while (!(otgp->ie[i].DIEPINT & DIEPINT_EPDISD)) - ; - } - else - otgp->ie[i].DIEPCTL = 0; + otgp->ie[i].DIEPCTL &= ~DIEPCTL_EPENA; otgp->ie[i].DIEPTSIZ = 0; otgp->ie[i].DIEPINT = 0xFFFFFFFF; - /* Disable only if enabled because this sentence in the manual: - "The application must set this bit only if Endpoint Enable is - already set for this endpoint". - Note that the attempt to disable the OUT EP0 is ignored by the - hardware but the code is simpler this way.*/ - if ((otgp->oe[i].DOEPCTL & DOEPCTL_EPENA) != 0) { - otgp->oe[i].DOEPCTL = DOEPCTL_EPDIS; - /* Wait for endpoint disable.*/ - while (!(otgp->oe[i].DOEPCTL & DOEPCTL_EPDIS)) - ; - } - else - otgp->oe[i].DOEPCTL = 0; + + otgp->oe[i].DOEPCTL &= ~DOEPCTL_EPENA; otgp->oe[i].DOEPTSIZ = 0; otgp->oe[i].DOEPINT = 0xFFFFFFFF; } diff --git a/testhal/STM32/STM32F7xx/USB_CDC/main.c b/testhal/STM32/STM32F7xx/USB_CDC/main.c index 73ad1ef18..a2b393720 100644 --- a/testhal/STM32/STM32F7xx/USB_CDC/main.c +++ b/testhal/STM32/STM32F7xx/USB_CDC/main.c @@ -213,10 +213,15 @@ int main(void) { chThdRelease(shelltp); /* Recovers memory of the previous shell. */ shelltp = NULL; /* Triggers spawning of a new shell. */ } +#if 0 if (palReadPad(GPIOI, GPIOI_BUTTON_USER)) { usbDisconnectBus(serusbcfg.usbp); usbStop(serusbcfg.usbp); + chThdSleepMilliseconds(1500); + usbStart(serusbcfg.usbp, &usbcfg); + usbConnectBus(serusbcfg.usbp); } +#endif chThdSleepMilliseconds(1000); } }