summaryrefslogtreecommitdiffstats
path: root/nuttx/arch/arm/src/stm32/stm32_otgfshost.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-08-28 22:28:49 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-08-28 22:28:49 +0000
commit298457d9a26dcc3d7ddefdee13fdf2dca62e3b27 (patch)
tree95dd623e1186c4415ee7eb277f57f0ed095355f0 /nuttx/arch/arm/src/stm32/stm32_otgfshost.c
parentd4d063b22adad543dddc12bbe49e91f03cb8f092 (diff)
Slightly improved delay logic for the USB host
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@5064 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/arch/arm/src/stm32/stm32_otgfshost.c')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_otgfshost.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfshost.c b/nuttx/arch/arm/src/stm32/stm32_otgfshost.c
index d888c52f14..6849049254 100644
--- a/nuttx/arch/arm/src/stm32/stm32_otgfshost.c
+++ b/nuttx/arch/arm/src/stm32/stm32_otgfshost.c
@@ -1474,7 +1474,7 @@ static int stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
FAR uint8_t *buffer, size_t buflen)
{
FAR struct stm32_chan_s *chan;
- int ret;
+ int ret = OK;
/* Loop until the transfer completes (i.e., buflen is decremented to zero)
* or a fatal error occurs (any error other than a simple NAK)
@@ -1484,6 +1484,17 @@ static int stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
chan->buffer = buffer;
chan->buflen = buflen;
+ /* There is a bug in the code at present. With debug OFF, this driver
+ * overruns the typical FLASH device and there are many problems with
+ * NAKS. Sticking a big delay here allows the device (FLASH drive) to
+ * catch up but sacrifices driver performance.
+ */
+
+#if !defined(CONFIG_DEBUG_VERBOSE) || !defined(CONFIG_DEBUG_USB)
+#warning "REVISIT this delay"
+ usleep(50*1000);
+#endif
+
while (chan->buflen > 0)
{
/* Set up for the wait BEFORE starting the transfer */
@@ -1537,17 +1548,6 @@ static int stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
}
}
- /* There is a bug in the code at present. With debug OFF, this driver
- * overruns the typical FLASH device and there are many problems with
- * NAKS sticking a big delay here allows the driver to work but with
- * very poor performance when debug is off.
- */
-
-#if !defined(CONFIG_DEBUG_VERBOSE) && !defined(CONFIG_DEBUG_USB)
-#warning "REVISIT this delay"
- usleep(100*1000);
-#endif
-
/* Start the transfer */
stm32_transfer_start(priv, chidx);
@@ -1557,18 +1557,30 @@ static int stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx,
ret = stm32_chan_wait(priv, chan);
/* EAGAIN indicates that the device NAKed the transfer and we need
- * do try again. Anything else (success or other errors) will
- * cause use to return
+ * do try again. NAK retries are not yet supported for OUT transfers
+ * so any unsuccessful response will cause us to abort the OUT
+ * transfer.
*/
if (ret != OK)
{
udbg("Transfer failed: %d\n", ret);
- return ret;
+ break;
}
}
- return OK;
+ /* There is a bug in the code at present. With debug OFF, this driver
+ * overruns the typical FLASH device and there are many problems with
+ * NAKS. Sticking a big delay here allows the device (FLASH drive) to
+ * catch up but sacrifices driver performance.
+ */
+
+#if !defined(CONFIG_DEBUG_VERBOSE) || !defined(CONFIG_DEBUG_USB)
+#warning "REVISIT this delay"
+ usleep(50*1000);
+#endif
+
+ return ret;
}
/*******************************************************************************
@@ -3086,9 +3098,9 @@ static int stm32_enumerate(FAR struct usbhost_driver_s *drvr)
priv->chan[chidx].indata1 = false;
priv->chan[chidx].outdata1 = false;
- /* USB 2.0 spec says at least 50ms delay before port reset */
+ /* USB 2.0 spec says at least 50ms delay before port reset. We wait 100ms. */
- up_mdelay(100);
+ usleep(100*1000);
/* Reset the host port */