summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-30 18:48:13 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-30 18:48:13 +0000
commit2587a85a2c3203de469826a73b7cc3661e88e997 (patch)
treea8a4315b6a5d984c3a424ea1d64ec338ffbe200d /nuttx/arch/arm/src/stm32/stm32_otgfsdev.c
parenta69f967be3c3d6b7029f3c2f4a9e5030819beeb7 (diff)
downloadnuttx-2587a85a2c3203de469826a73b7cc3661e88e997.tar.gz
nuttx-2587a85a2c3203de469826a73b7cc3661e88e997.tar.bz2
nuttx-2587a85a2c3203de469826a73b7cc3661e88e997.zip
LM4F update from JP
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5586 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/stm32/stm32_otgfsdev.c')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_otgfsdev.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c
index 94772b693..9307545a3 100644
--- a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c
+++ b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c
@@ -184,8 +184,9 @@
#define STM32_TRACEERR_NOEP 0x18
#define STM32_TRACEERR_NOTCONFIGURED 0x19
#define STM32_TRACEERR_EPOUTQEMPTY 0x1a
-#define STM32_TRACEERR_EPINQEMPTY 0x1b
+#define STM32_TRACEERR_EPINREQEMPTY 0x1b
#define STM32_TRACEERR_NOOUTSETUP 0x1c
+#define STM32_TRACEERR_POLLTIMEOUT 0x1d
/* Trace interrupt codes */
@@ -1084,6 +1085,7 @@ static void stm32_epin_request(FAR struct stm32_usbdev_s *priv,
uint32_t regval;
#ifdef ENABLE_DTXFSTS_POLLHACK
int32_t timeout;
+ int avail;
#endif
uint8_t *buf;
int nbytes;
@@ -1113,7 +1115,7 @@ static void stm32_epin_request(FAR struct stm32_usbdev_s *priv,
privreq = stm32_rqpeek(privep);
if (!privreq)
{
- usbtrace(TRACE_DEVERROR(STM32_TRACEERR_EPINQEMPTY), privep->epphy);
+ usbtrace(TRACE_DEVERROR(STM32_TRACEERR_EPINREQEMPTY), privep->epphy);
/* There is no TX transfer in progress and no new pending TX
* requests to send. To stop transmitting any data on a particular
@@ -1221,18 +1223,28 @@ static void stm32_epin_request(FAR struct stm32_usbdev_s *priv,
#ifdef ENABLE_DTXFSTS_POLLHACK
/* If ENABLE_DTXFSTS_POLLHACK is enabled , then poll DTXFSTS until
- * space in the TxFIFO is available. If it doesn't become available,
- * in a reasonable amount of time, then just pretend that it is.
+ * space in the TxFIFO is available.
*/
for (timeout = 250000; timeout > 0; timeout--)
{
- regval = stm32_getreg(regaddr);
- if ((regval & OTGFS_DTXFSTS_MASK) >= nwords)
+ avail = stm32_getreg(regaddr) & OTGFS_DTXFSTS_MASK;
+ if (avail >= nwords)
{
break;
}
}
+
+ /* If it did not become available in a reasonable amount of time,
+ * then just return. We should come back through this logic later
+ * anyway.
+ */
+
+ if (avail < nwords)
+ {
+ usbtrace(TRACE_DEVERROR(STM32_TRACEERR_POLLTIMEOUT), avail);
+ return;
+ }
#else
/* If ENABLE_DTXFSTS_POLLHACK is not enabled, then check once for
* space in the TxFIFO. If space in the TxFIFO is not available,
@@ -1290,11 +1302,12 @@ static void stm32_epin_request(FAR struct stm32_usbdev_s *priv,
if (privreq->req.xfrd >= privreq->req.len && !privep->zlp)
{
usbtrace(TRACE_COMPLETE(privep->epphy), privreq->req.xfrd);
- stm32_req_complete(privep, OK);
- /* The endpoint is no longer transferring data */
+ /* We are finished with the request (although the transfer has not
+ * yet completed).
+ */
- privep->active = false;
+ stm32_req_complete(privep, OK);
}
}