diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-01-09 15:35:08 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-01-09 15:35:08 +0000 |
commit | 29c706c9e17447ef58198c36168457c37a00ff4e (patch) | |
tree | 9d83ade9fa10c17da6252dc45d29bd5bf1c8ed70 | |
parent | 5bdca5bec60da89395a77402c0eea7d0c627eb98 (diff) | |
download | nuttx-29c706c9e17447ef58198c36168457c37a00ff4e.tar.gz nuttx-29c706c9e17447ef58198c36168457c37a00ff4e.tar.bz2 nuttx-29c706c9e17447ef58198c36168457c37a00ff4e.zip |
Basic USB host functionality in place
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3236 42af7a65-404d-4744-a932-0658087f49c3
-rwxr-xr-x | nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c | 29 | ||||
-rwxr-xr-x | nuttx/include/nuttx/usb/ohci.h | 2 | ||||
-rw-r--r-- | nuttx/include/nuttx/usb/usbhost.h | 4 |
3 files changed, 29 insertions, 6 deletions
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 */ diff --git a/nuttx/include/nuttx/usb/ohci.h b/nuttx/include/nuttx/usb/ohci.h index c20e34b3e..c19b2d3d8 100755 --- a/nuttx/include/nuttx/usb/ohci.h +++ b/nuttx/include/nuttx/usb/ohci.h @@ -401,7 +401,7 @@ struct ohci_gtd_s struct ohci_itd_s { - volatile uint32_t status; /* TD status/control bits */ + volatile uint32_t ctrl; /* TD status/control bits */ volatile uint32_t bp0; /* Buffer page 0 (BP0 */ volatile uint32_t nexttd; /* Next TD (NextTD) */ volatile uint32_t be; /* Buffer End (BE) */ diff --git a/nuttx/include/nuttx/usb/usbhost.h b/nuttx/include/nuttx/usb/usbhost.h index 2f02056f6..a83048f68 100644 --- a/nuttx/include/nuttx/usb/usbhost.h +++ b/nuttx/include/nuttx/usb/usbhost.h @@ -526,10 +526,10 @@ struct usbhost_driver_s struct usbhost_epdesc_s { uint8_t addr : 4; /* Endpoint address */ - uint8_t pad1 : 3; + uint8_t pad : 3; uint8_t in : 1; /* Direction: 1->IN */ uint8_t funcaddr : 7; /* USB address of function containing endpoint */ - uint8_t pad2 : 1; + uint8_t toggle : 1; /* Last toggle (modified by the driver) */ uint16_t mxpacketsize; /* Max packetsize */ }; |