summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-01-02 20:05:28 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-01-02 20:05:28 +0000
commit1790044dc64c1edd78db07c19c910fa9fd794f9c (patch)
tree6e834dfe12f90f21e7907c6b1e519a28399e3438
parentc9cd8b75048e6a0b8b41ece1da572b032aba67c7 (diff)
downloadnuttx-1790044dc64c1edd78db07c19c910fa9fd794f9c.tar.gz
nuttx-1790044dc64c1edd78db07c19c910fa9fd794f9c.tar.bz2
nuttx-1790044dc64c1edd78db07c19c910fa9fd794f9c.zip
FunctionAddress no longer hard-coded
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3231 42af7a65-404d-4744-a932-0658087f49c3
-rwxr-xr-xnuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c8
-rwxr-xr-xnuttx/drivers/usbhost/usbhost_enumerate.c15
-rw-r--r--nuttx/drivers/usbhost/usbhost_storage.c16
-rw-r--r--nuttx/include/nuttx/usb/usbhost.h19
4 files changed, 39 insertions, 19 deletions
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
index d9b994440..6a1fbeeb2 100755
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
@@ -929,10 +929,12 @@ static int lpc17_enumerate(FAR struct usbhost_driver_s *drvr)
lpc17_putreg(OHCI_RHPORTST_PRSC, LPC17_USBHOST_RHPORTST1);
up_mdelay(200);
- /* Let the common usbhost_enumerate do all of the real work */
+ /* Let the common usbhost_enumerate do all of the real work. Note that the
+ * FunctionAddress (USB address) is hardcoded to one.
+ */
uvdbg("Enumerate the device\n");
- return usbhost_enumerate(drvr, &priv->class);
+ return usbhost_enumerate(drvr, 1, &priv->class);
}
/************************************************************************************
@@ -1239,7 +1241,7 @@ static int lpc17_transfer(FAR struct usbhost_driver_s *drvr,
/* Get the direction of the endpoint */
- if (ep->in)
+ if (ep->in != 0)
{
ed->ctrl |= ED_CONTROL_D_IN;
dirpid = GTD_STATUS_DP_IN;
diff --git a/nuttx/drivers/usbhost/usbhost_enumerate.c b/nuttx/drivers/usbhost/usbhost_enumerate.c
index cb82b6b14..035f8a3c1 100755
--- a/nuttx/drivers/usbhost/usbhost_enumerate.c
+++ b/nuttx/drivers/usbhost/usbhost_enumerate.c
@@ -72,7 +72,7 @@ static inline int usbhost_configdesc(const uint8_t *configdesc, int desclen,
struct usbhost_id_s *id);
static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
const uint8_t *configdesc, int desclen,
- struct usbhost_id_s *id,
+ struct usbhost_id_s *id, uint8_t funcaddr,
FAR struct usbhost_class_s **class);
/*******************************************************************************
@@ -235,7 +235,7 @@ static inline int usbhost_configdesc(const uint8_t *configdesc, int cfglen,
static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
const uint8_t *configdesc, int desclen,
- struct usbhost_id_s *id,
+ struct usbhost_id_s *id, uint8_t funcaddr,
FAR struct usbhost_class_s **class)
{
FAR struct usbhost_class_s *devclass;
@@ -264,7 +264,7 @@ static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
{
/* Then bind the newly instantiated class instance */
- ret = CLASS_CONNECT(devclass, configdesc, desclen);
+ ret = CLASS_CONNECT(devclass, configdesc, desclen, funcaddr);
if (ret != OK)
{
udbg("CLASS_CONNECT failed: %d\n", ret);
@@ -301,6 +301,11 @@ static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
* Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to
* the class create() method.
+ * funcaddr - The USB address of the function containing the endpoint that EP0
+ * controls
+ * class - If the class driver for the device is successful located
+ * and bound to the driver, the allocated class instance is returned into
+ * this caller-provided memory location.
*
* Returned Values:
* On success, zero (OK) is returned. On a failure, a negated errno value is
@@ -313,7 +318,7 @@ static inline int usbhost_classbind(FAR struct usbhost_driver_s *drvr,
*
*******************************************************************************/
-int usbhost_enumerate(FAR struct usbhost_driver_s *drvr,
+int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
FAR struct usbhost_class_s **class)
{
struct usb_ctrlreq_s *ctrlreq;
@@ -498,7 +503,7 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr,
* will begin configuring the device.
*/
- ret = usbhost_classbind(drvr, buffer, cfglen, &id, class);
+ ret = usbhost_classbind(drvr, buffer, cfglen, &id, funcaddr, class);
if (ret != OK)
{
udbg("ERROR: usbhost_classbind returned %d\n", ret);
diff --git a/nuttx/drivers/usbhost/usbhost_storage.c b/nuttx/drivers/usbhost/usbhost_storage.c
index 8bc5197c1..21a87c5b0 100644
--- a/nuttx/drivers/usbhost/usbhost_storage.c
+++ b/nuttx/drivers/usbhost/usbhost_storage.c
@@ -213,7 +213,8 @@ static struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *drvr,
/* struct usbhost_class_s methods */
static int usbhost_connect(FAR struct usbhost_class_s *class,
- FAR const uint8_t *configdesc, int desclen);
+ FAR const uint8_t *configdesc, int desclen,
+ uint8_t funcaddr);
static int usbhost_disconnected(FAR struct usbhost_class_s *class);
/* struct block_operations methods */
@@ -1391,6 +1392,8 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d
* class - The USB host class entry previously obtained from a call to create().
* configdesc - A pointer to a uint8_t buffer container the configuration descripor.
* desclen - The length in bytes of the configuration descriptor.
+ * funcaddr - The USB address of the function containing the endpoint that EP0
+ * controls
*
* Returned Values:
* On success, zero (OK) is returned. On a failure, a negated errno value is
@@ -1404,7 +1407,8 @@ static FAR struct usbhost_class_s *usbhost_create(FAR struct usbhost_driver_s *d
****************************************************************************/
static int usbhost_connect(FAR struct usbhost_class_s *class,
- FAR const uint8_t *configdesc, int desclen)
+ FAR const uint8_t *configdesc, int desclen,
+ uint8_t funcaddr)
{
FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)class;
FAR struct usb_cfgdesc_s *cfgdesc;
@@ -1490,8 +1494,8 @@ static int usbhost_connect(FAR struct usbhost_class_s *class,
/* Save the bulk OUT endpoint information */
priv->bulkout.addr = epdesc->addr & USB_EP_ADDR_NUMBER_MASK;
- priv->bulkout.in = false;
- priv->bulkout.funcaddr = 1;
+ priv->bulkout.in = 0;
+ priv->bulkout.funcaddr = funcaddr;
priv->bulkout.mxpacketsize = usbhost_getle16(epdesc->mxpacketsize);
uvdbg("Bulk OUT EP addr:%d mxpacketsize:%d\n",
priv->bulkout.addr, priv->bulkout.mxpacketsize);
@@ -1511,8 +1515,8 @@ static int usbhost_connect(FAR struct usbhost_class_s *class,
/* Save the bulk IN endpoint information */
priv->bulkin.addr = epdesc->addr & USB_EP_ADDR_NUMBER_MASK;
- priv->bulkin.in = true;
- priv->bulkin.funcaddr = 1;
+ priv->bulkin.in = 1;
+ priv->bulkin.funcaddr = funcaddr;
priv->bulkin.mxpacketsize = usbhost_getle16(epdesc->mxpacketsize);
uvdbg("Bulk IN EP addr:%d mxpacketsize:%d\n",
priv->bulkin.addr, priv->bulkin.mxpacketsize);
diff --git a/nuttx/include/nuttx/usb/usbhost.h b/nuttx/include/nuttx/usb/usbhost.h
index 9d7919839..2f02056f6 100644
--- a/nuttx/include/nuttx/usb/usbhost.h
+++ b/nuttx/include/nuttx/usb/usbhost.h
@@ -106,6 +106,8 @@
* class - The USB host class entry previously obtained from a call to create().
* configdesc - A pointer to a uint8_t buffer container the configuration descripor.
* desclen - The length in bytes of the configuration descriptor.
+ * funcaddr - The USB address of the function containing the endpoint that EP0
+ * controls
*
* Returned Values:
* On success, zero (OK) is returned. On a failure, a negated errno value is
@@ -118,7 +120,8 @@
*
************************************************************************************/
-#define CLASS_CONNECT(class,configdesc,desclen) ((class)->connect(class,configdesc,desclen))
+#define CLASS_CONNECT(class,configdesc,desclen,funcaddr) \
+ ((class)->connect(class,configdesc,desclen, funcaddr))
/************************************************************************************
* Name: CLASS_DISCONNECTED
@@ -430,7 +433,8 @@ struct usbhost_class_s
* initialize properly (such as endpoint selections).
*/
- int (*connect)(FAR struct usbhost_class_s *class, FAR const uint8_t *configdesc, int desclen);
+ int (*connect)(FAR struct usbhost_class_s *class, FAR const uint8_t *configdesc,
+ int desclen, uint8_t funcaddr);
/* This method informs the class that the USB device has been disconnected. */
@@ -521,9 +525,11 @@ struct usbhost_driver_s
struct usbhost_epdesc_s
{
- uint8_t addr; /* Endpoint address */
- bool in; /* Direction: TRUE = IN */
- uint8_t funcaddr; /* USB address of function containing endpoint */
+ uint8_t addr : 4; /* Endpoint address */
+ uint8_t pad1 : 3;
+ uint8_t in : 1; /* Direction: 1->IN */
+ uint8_t funcaddr : 7; /* USB address of function containing endpoint */
+ uint8_t pad2 : 1;
uint16_t mxpacketsize; /* Max packetsize */
};
@@ -653,6 +659,8 @@ EXTERN FAR struct usbhost_driver_s *usbhost_initialize(int controller);
* Input Parameters:
* drvr - The USB host driver instance obtained as a parameter from the call to
* the class create() method.
+ * funcaddr - The USB address of the function containing the endpoint that EP0
+ * controls
* class - If the class driver for the device is successful located
* and bound to the driver, the allocated class instance is returned into
* this caller-provided memory location.
@@ -669,6 +677,7 @@ EXTERN FAR struct usbhost_driver_s *usbhost_initialize(int controller);
*******************************************************************************/
EXTERN int usbhost_enumerate(FAR struct usbhost_driver_s *drvr,
+ uint8_t funcaddr,
FAR struct usbhost_class_s **class);
#undef EXTERN