summaryrefslogtreecommitdiff
path: root/nuttx/drivers/usbhost
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 /nuttx/drivers/usbhost
parentc9cd8b75048e6a0b8b41ece1da572b032aba67c7 (diff)
downloadpx4-nuttx-1790044dc64c1edd78db07c19c910fa9fd794f9c.tar.gz
px4-nuttx-1790044dc64c1edd78db07c19c910fa9fd794f9c.tar.bz2
px4-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
Diffstat (limited to 'nuttx/drivers/usbhost')
-rwxr-xr-xnuttx/drivers/usbhost/usbhost_enumerate.c15
-rw-r--r--nuttx/drivers/usbhost/usbhost_storage.c16
2 files changed, 20 insertions, 11 deletions
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);