From 973efabddb56fc8454c1e27397d2a0a04064a18c Mon Sep 17 00:00:00 2001 From: Jochen Hoenicke Date: Thu, 7 Jul 2016 16:50:52 +0200 Subject: [PATCH] stmfx07: usb: poll DIEPINT before RXFLVL This is to interrupt for setup sequences on IN packet before checking for OUT packet received. This fixes the problem that usb_control_out stalls because we are not yet in STATUS_OUT phase. Related to #668. --- lib/usb/usb_fx07_common.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/usb/usb_fx07_common.c b/lib/usb/usb_fx07_common.c index edd10ada..f09416cd 100644 --- a/lib/usb/usb_fx07_common.c +++ b/lib/usb/usb_fx07_common.c @@ -262,6 +262,23 @@ void stm32fx07_poll(usbd_device *usbd_dev) return; } + /* + * There is no global interrupt flag for transmit complete. + * The XFRC bit must be checked in each OTG_DIEPINT(x). + */ + for (i = 0; i < 4; i++) { /* Iterate over endpoints. */ + if (REBASE(OTG_DIEPINT(i)) & OTG_DIEPINTX_XFRC) { + /* Transfer complete. */ + if (usbd_dev->user_callback_ctr[i] + [USB_TRANSACTION_IN]) { + usbd_dev->user_callback_ctr[i] + [USB_TRANSACTION_IN](usbd_dev, i); + } + + REBASE(OTG_DIEPINT(i)) = OTG_DIEPINTX_XFRC; + } + } + /* Note: RX and TX handled differently in this device. */ if (intsts & OTG_GINTSTS_RXFLVL) { /* Receive FIFO non-empty. */ @@ -304,23 +321,6 @@ void stm32fx07_poll(usbd_device *usbd_dev) usbd_dev->rxbcnt = 0; } - /* - * There is no global interrupt flag for transmit complete. - * The XFRC bit must be checked in each OTG_DIEPINT(x). - */ - for (i = 0; i < 4; i++) { /* Iterate over endpoints. */ - if (REBASE(OTG_DIEPINT(i)) & OTG_DIEPINTX_XFRC) { - /* Transfer complete. */ - if (usbd_dev->user_callback_ctr[i] - [USB_TRANSACTION_IN]) { - usbd_dev->user_callback_ctr[i] - [USB_TRANSACTION_IN](usbd_dev, i); - } - - REBASE(OTG_DIEPINT(i)) = OTG_DIEPINTX_XFRC; - } - } - if (intsts & OTG_GINTSTS_USBSUSP) { if (usbd_dev->user_callback_suspend) { usbd_dev->user_callback_suspend();