aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/OTGv1
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-08-20 10:04:44 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-08-20 10:04:44 +0000
commit15f4e5c3f36595e9fb03a9143fe6d52183700220 (patch)
treefb4a5449c285afbf946f23f11688af5adc6f4192 /os/hal/ports/STM32/LLD/OTGv1
parent190694efa4571da760e0514880db45f9a779e1c1 (diff)
downloadChibiOS-15f4e5c3f36595e9fb03a9143fe6d52183700220.tar.gz
ChibiOS-15f4e5c3f36595e9fb03a9143fe6d52183700220.tar.bz2
ChibiOS-15f4e5c3f36595e9fb03a9143fe6d52183700220.zip
Tentative workaround for L4 OTG driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10453 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/STM32/LLD/OTGv1')
-rw-r--r--os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c15
-rw-r--r--os/hal/ports/STM32/LLD/OTGv1/stm32_otg.h1
2 files changed, 13 insertions, 3 deletions
diff --git a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c
index b0bb9aa3e..7490c2c8b 100644
--- a/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c
+++ b/os/hal/ports/STM32/LLD/OTGv1/hal_usb_lld.c
@@ -418,10 +418,19 @@ static void otg_epout_handler(USBDriver *usbp, usbep_t ep) {
if ((epint & DOEPINT_XFRC) && (otgp->DOEPMSK & DOEPMSK_XFRCM)) {
USBOutEndpointState *osp;
+#if defined(STM32_OTG_SEQUENCE_WORKAROUND)
+ /* If an OUT transaction end interrupt is processed after the state
+ machine advanced to an IN state then it is ignored, this is caused
+ on some devices (L4) by STUP and XFRCM interrupts arriving in random
+ order.*/
+ if ((ep == 0) && ((usbp->ep0state & USB_OUT_STATE) == 0))
+ return;
+#else
/* Receive transfer complete, checking if it is a SETUP transfer on EP0,
- than it must be ignored, the STUPM handler will take care of it.*/
- if ((ep == 0) && (usbp->ep0state == USB_EP0_WAITING_SETUP))
+ than it must be ignored, the STUP handler will take care of it.*/
+ if ((ep == 0) && (usbp->ep0state == USB_EP0_STP_WAITING))
return;
+#endif
/* OUT state structure pointer for this endpoint.*/
osp = usbp->epc[ep]->out_state;
@@ -994,7 +1003,7 @@ void usb_lld_reset(USBDriver *usbp) {
/* EP0 initialization, it is a special case.*/
usbp->epc[0] = &ep0config;
- otgp->oe[0].DOEPTSIZ = 0;
+ otgp->oe[0].DOEPTSIZ = DOEPTSIZ_STUPCNT(3);
otgp->oe[0].DOEPCTL = DOEPCTL_SD0PID | DOEPCTL_USBAEP | DOEPCTL_EPTYP_CTRL |
DOEPCTL_MPSIZ(ep0config.out_maxsize);
otgp->ie[0].DIEPTSIZ = 0;
diff --git a/os/hal/ports/STM32/LLD/OTGv1/stm32_otg.h b/os/hal/ports/STM32/LLD/OTGv1/stm32_otg.h
index 00b67b32a..6b326895f 100644
--- a/os/hal/ports/STM32/LLD/OTGv1/stm32_otg.h
+++ b/os/hal/ports/STM32/LLD/OTGv1/stm32_otg.h
@@ -862,6 +862,7 @@ typedef struct {
* @name DOEPINT register bit definitions
* @{
*/
+#define DOEPINT_SETUP_RCVD (1U<<15) /**< SETUP packet received. */
#define DOEPINT_B2BSTUP (1U<<6) /**< Back-to-back SETUP packets
received. */
#define DOEPINT_OTEPDIS (1U<<4) /**< OUT token received when