summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-15 22:56:46 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-03-15 22:56:46 +0000
commitb41ddbd4ae44708b90316e31ae95c01cb540b09d (patch)
tree1818dd1a3bfc0355cf2ae09f887254733336680e /nuttx
parent646e343fe6bb56f5a8898265b858c0833a3a0bb4 (diff)
downloadpx4-nuttx-b41ddbd4ae44708b90316e31ae95c01cb540b09d.tar.gz
px4-nuttx-b41ddbd4ae44708b90316e31ae95c01cb540b09d.tar.bz2
px4-nuttx-b41ddbd4ae44708b90316e31ae95c01cb540b09d.zip
Fix PIC32 USB double buffer toggle
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4492 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c b/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c
index b0a73dc20..d50c938ab 100644
--- a/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c
+++ b/nuttx/arch/mips/src/pic32mx/pic32mx-usbdev.c
@@ -2259,31 +2259,17 @@ static void pic32mx_ep0incomplete(struct pic32mx_usbdev_s *priv)
{
struct pic32mx_ep_s *ep0 = &priv->eplist[EP0];
volatile struct usbotg_bdtentry_s *bdtlast;
- volatile struct usbotg_bdtentry_s *bdtnext;
int ret;
- /* Get the last and the next IN BDT */
+ /* Get the last BDT and make sure that we own it. */
bdtlast = ep0->bdtin;
- if (bdtlast == &g_bdt[EP0_IN_EVEN])
- {
- bdtnext = &g_bdt[EP0_IN_ODD];
- }
- else
- {
- DEBUGASSERT(bdtlast == &g_bdt[EP0_IN_ODD]);
- bdtnext = &g_bdt[EP0_IN_EVEN];
- }
/* Make sure that we own the last BDT. */
bdtlast->status = 0;
bdtlast->addr = 0;
- /* Save the next BDT as the current BDT */
-
- ep0->bdtin = bdtnext;
-
/* Are we processing the completion of one packet of an outgoing request
* from the class driver?
*/
@@ -2292,6 +2278,9 @@ static void pic32mx_ep0incomplete(struct pic32mx_usbdev_s *priv)
{
/* An outgoing EP0 transfer has completed. Update the byte count and
* check for the completion of the transfer.
+ *
+ * NOTE: pic32mx_wrcomplete() will toggle bdtin to the other buffer so
+ * we do not need to that for this case.
*/
pic32mx_wrcomplete(priv, &priv->eplist[EP0]);
@@ -2318,6 +2307,18 @@ static void pic32mx_ep0incomplete(struct pic32mx_usbdev_s *priv)
else if (priv->ctrlstate == CTRLSTATE_WAITSETUP)
{
+ /* Get the next IN BDT */
+
+ if (bdtlast == &g_bdt[EP0_IN_EVEN])
+ {
+ ep0->bdtin = &g_bdt[EP0_IN_ODD];
+ }
+ else
+ {
+ DEBUGASSERT(bdtlast == &g_bdt[EP0_IN_ODD]);
+ ep0->bdtin = &g_bdt[EP0_IN_EVEN];
+ }
+
/* Look at the saved SETUP command. Was it a SET ADDRESS request?
* If so, then now is the time to set the address.
*/