From 29c706c9e17447ef58198c36168457c37a00ff4e Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 9 Jan 2011 15:35:08 +0000 Subject: Basic USB host functionality in place git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3236 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'nuttx/arch/arm') diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c index 9b73ed0d2..950a0ffe7 100755 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c @@ -1282,8 +1282,8 @@ static int lpc17_transfer(FAR struct usbhost_driver_s *drvr, int ret; DEBUGASSERT(drvr && ep && buffer && buflen > 0); - uvdbg("EP%d %s maxpacket:%d buflen:%d\n", - ep->addr, ep->in ? "IN" : "OUT", ep->mxpacketsize, buflen); + uvdbg("EP%d %s toggle:%d maxpacket:%d buflen:%d\n", + ep->addr, ep->in ? "IN" : "OUT", ep->toggle, ep->mxpacketsize, buflen); /* Allocate an IO buffer if the user buffer does not lie in AHB SRAM */ @@ -1346,7 +1346,9 @@ static int lpc17_transfer(FAR struct usbhost_driver_s *drvr, goto errout; } - /* Format the endpoint descriptor */ + /* Format the endpoint descriptor. This could be a lot simpler if + * the OHCI ED structure were exposed outside of the driver. + */ lpc17_edinit(ed); ed->ctrl = (uint32_t)(ep->funcaddr) << ED_CONTROL_FA_SHIFT | @@ -1366,6 +1368,13 @@ static int lpc17_transfer(FAR struct usbhost_driver_s *drvr, dirpid = GTD_STATUS_DP_OUT; } + /* Set/restore the toggle carry bit */ + + if (ep->toggle) + { + ed->headp = ED_HEADP_C; + } + /* Then enqueue the transfer */ priv->tdstatus = TD_CC_NOERROR; @@ -1411,6 +1420,20 @@ static int lpc17_transfer(FAR struct usbhost_driver_s *drvr, ret = -EIO; } + /* Save the toggle carry bit. This bit is updated each time that an + * ED is retired. This could be a lot simpler if the OHCI ED structure + * were exposed outside of the driver. + */ + + if ((ed->headp & ED_HEADP_C) != 0) + { + ep->toggle = 1; + } + else + { + ep->toggle = 0; + } + errout: /* Free any temporary IO buffers */ -- cgit v1.2.3