summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/ChangeLog6
-rw-r--r--nuttx/Documentation/NuttxPortingGuide.html14
-rw-r--r--nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c35
-rw-r--r--nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.h4
-rw-r--r--nuttx/arch/arm/src/sama5/sam_ohci.c34
-rw-r--r--nuttx/arch/arm/src/sama5/sam_usbhost.h4
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_otgfs.h4
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_otgfshost.c35
-rw-r--r--nuttx/configs/cloudctrl/src/up_usb.c10
-rw-r--r--nuttx/configs/mikroe-stm32f4/src/up_usb.c10
-rw-r--r--nuttx/configs/olimex-lpc1766stk/src/up_nsh.c10
-rw-r--r--nuttx/configs/open1788/src/lpc17_nsh.c10
-rw-r--r--nuttx/configs/pic32-starterkit/src/up_nsh.c10
-rw-r--r--nuttx/configs/pic32mx7mmb/src/up_nsh.c10
-rw-r--r--nuttx/configs/sama5d3x-ek/src/sam_usb.c22
-rw-r--r--nuttx/configs/shenzhou/src/up_usb.c10
-rw-r--r--nuttx/configs/stm3220g-eval/src/up_usb.c10
-rw-r--r--nuttx/configs/stm3240g-eval/src/up_usb.c10
-rw-r--r--nuttx/configs/stm32f4discovery/src/up_usb.c10
-rw-r--r--nuttx/configs/sure-pic32mx/src/pic32mx_nsh.c10
-rw-r--r--nuttx/include/nuttx/usb/usbhost.h34
21 files changed, 169 insertions, 133 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index fa6401252..9651e94f9 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -5391,4 +5391,8 @@
in up_putc(). I think all architectures have this re-entrancy
than can result in serial interrupt being disabled, but I have only
seen the symptom on SAMA5 (2013-8-13).
-
+ * includes/nuttx/usb/usbhost.h and many other affected files: Separate
+ wait() and enumerate() methods from struct usbhost_driver_s and move
+ to new interface, struct usbhost_connection_s. This is part of the
+ necessary restructuring of the USB host interface to support multiple
+ root hub ports (2013-8-13).
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html
index 71bb5842c..adfc5d36e 100644
--- a/nuttx/Documentation/NuttxPortingGuide.html
+++ b/nuttx/Documentation/NuttxPortingGuide.html
@@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec">
<i>NuttX RTOS Porting Guide</i>
</font></big></h1>
- <p>Last Updated: August 12, 2013</p>
+ <p>Last Updated: August 13, 2013</p>
</td>
</tr>
</table>
@@ -3426,9 +3426,11 @@ extern void up_ledoff(int led);
</li>
<li>
<p>
- <b><code>struct usbhost_driver_s</code></b>.
- Each USB host controller driver must implement an instance of <code>struct usbhost_driver_s</code>.
- This structure is defined in <code>include/nuttx/usb/usbhost.h</code>.
+ <b><code>struct usbhost_driver_s</code> and <code>struct usbhost_connection_s</code></b>.
+ Each USB host controller driver must implement an instance of <code>struct usbhost_driver_s</code> and <code>struct usbhost_connection_s</code>:
+ <code>struct usbhost_driver_s</code> provides the interface between the USB host driver and the USB class driver;
+ <code>struct usbhost_connection_s</code> provides the interface between the USB host driver and platform-specific connection management and device enumeration logoc.
+ These structures are defined in <code>include/nuttx/usb/usbhost.h</code>.
</p>
<p>
<b>Examples</b>:
@@ -3471,7 +3473,7 @@ extern void up_ledoff(int led);
<ul>
<li>
<p>
- <code>int (*wait)(FAR struct usbhost_driver_s *drvr, FAR const bool *connected);</code>
+ <code>int (*wait)(FAR struct usbhost_connection_s *drvr, FAR const bool *connected);</code>
</p>
<p>
Wait for a device to be connected or disconnected.
@@ -3479,7 +3481,7 @@ extern void up_ledoff(int led);
</li>
<li>
<p>
- <code>int (*enumerate)(FAR struct usbhost_driver_s *drvr, int rhpndx);</code>
+ <code>int (*enumerate)(FAR struct usbhost_connection_s *drvr, int rhpndx);</code>
</p>
<p>
Enumerate the device connected to a root hub port.
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
index fbf2b214d..11ec7fdc0 100644
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
@@ -294,8 +294,9 @@ static int lpc17_usbinterrupt(int irq, FAR void *context);
/* USB host controller operations **********************************************/
-static int lpc17_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected);
-static int lpc17_enumerate(FAR struct usbhost_driver_s *drvr, int rhpndx);
+static int lpc17_wait(FAR struct usbhost_connection_s *conn, FAR bool *connected);
+static int lpc17_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx);
+
static int lpc17_ep0configure(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
uint16_t maxpacketsize);
static int lpc17_epalloc(FAR struct usbhost_driver_s *drvr,
@@ -334,8 +335,6 @@ static struct lpc17_usbhost_s g_usbhost =
{
.drvr =
{
- .wait = lpc17_wait,
- .enumerate = lpc17_enumerate,
.ep0configure = lpc17_ep0configure,
.epalloc = lpc17_epalloc,
.epfree = lpc17_epfree,
@@ -351,6 +350,14 @@ static struct lpc17_usbhost_s g_usbhost =
.class = NULL,
};
+/* This is the connection/enumeration interact */
+
+static struct usbhost_connection_s g_usbconn =
+{
+ .wait = lpc17_wait,
+ .enumerate = lpc17_enumerate,
+};
+
/* This is a free list of EDs and TD buffers */
static struct lpc17_list_s *g_edfree; /* List of unused EDs */
@@ -1516,8 +1523,8 @@ static int lpc17_usbinterrupt(int irq, FAR void *context)
* Wait for a device to be connected or disconneced.
*
* Input Parameters:
- * drvr - The USB host driver instance obtained as a parameter from the call to
- * the class create() method.
+ * conn - The USB host connection instance obtained as a parameter from the call to
+ * the USB driver initialization logic.
* connected - A pointer to a boolean value: TRUE: Wait for device to be
* connected; FALSE: wait for device to be disconnected
*
@@ -1533,9 +1540,9 @@ static int lpc17_usbinterrupt(int irq, FAR void *context)
*
*******************************************************************************/
-static int lpc17_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected)
+static int lpc17_wait(FAR struct usbhost_connection_s *conn, FAR bool *connected)
{
- struct lpc17_usbhost_s *priv = (struct lpc17_usbhost_s *)drvr;
+ struct lpc17_usbhost_s *priv = (struct lpc17_usbhost_s *)&g_usbhost;
irqstate_t flags;
/* Are we already connected? */
@@ -1569,8 +1576,8 @@ static int lpc17_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected)
* charge of the sequence of operations.
*
* Input Parameters:
- * drvr - The USB host driver instance obtained as a parameter from the call to
- * the class create() method.
+ * conn - The USB host connection instance obtained as a parameter from the call to
+ * the USB driver initialization logic.
* rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n.
*
* Returned Values:
@@ -1584,9 +1591,9 @@ static int lpc17_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected)
*
*******************************************************************************/
-static int lpc17_enumerate(FAR struct usbhost_driver_s *drvr, int rphndx)
+static int lpc17_enumerate(FAR struct usbhost_connection_s *conn, int rphndx)
{
- struct lpc17_usbhost_s *priv = (struct lpc17_usbhost_s *)drvr;
+ struct lpc17_usbhost_s *priv = (struct lpc17_usbhost_s *)&g_usbhost;
DEBUGASSERT(priv && rhpndx == 0);
/* Are we connected to a device? The caller should have called the wait()
@@ -2479,7 +2486,7 @@ static inline void lpc17_ep0init(struct lpc17_usbhost_s *priv)
*
*******************************************************************************/
-FAR struct usbhost_driver_s *usbhost_initialize(int controller)
+FAR struct usbhost_connection_s *usbhost_initialize(int controller)
{
struct lpc17_usbhost_s *priv = &g_usbhost;
uint32_t regval;
@@ -2707,5 +2714,5 @@ FAR struct usbhost_driver_s *usbhost_initialize(int controller)
udbg("USB host Initialized, Device connected:%s\n",
priv->connected ? "YES" : "NO");
- return &priv->drvr;
+ return &g_usbconn;
}
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.h b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.h
index d473db9a6..715d6976f 100644
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.h
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.h
@@ -93,8 +93,8 @@ extern "C"
*******************************************************************************/
#ifdef CONFIG_USBHOST
-struct usbhost_driver_s;
-FAR struct usbhost_driver_s *usbhost_initialize(int controller);
+struct usbhost_connection_s;
+FAR struct usbhost_connection_s *usbhost_initialize(int controller);
#endif
#undef EXTERN
diff --git a/nuttx/arch/arm/src/sama5/sam_ohci.c b/nuttx/arch/arm/src/sama5/sam_ohci.c
index ff45f7bb0..c5a46f597 100644
--- a/nuttx/arch/arm/src/sama5/sam_ohci.c
+++ b/nuttx/arch/arm/src/sama5/sam_ohci.c
@@ -351,8 +351,9 @@ static int sam_ohci_interrupt(int irq, FAR void *context);
/* USB host controller operations **********************************************/
-static int sam_wait(FAR struct usbhost_driver_s *drvr, FAR const bool *connected);
-static int sam_enumerate(FAR struct usbhost_driver_s *drvr, int rhpndx);
+static int sam_wait(FAR struct usbhost_connection_s *conn, FAR const bool *connected);
+static int sam_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx);
+
static int sam_ep0configure(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
uint16_t maxpacketsize);
static int sam_epalloc(FAR struct usbhost_driver_s *drvr,
@@ -391,8 +392,6 @@ static struct sam_ohci_s g_usbhost =
{
.drvr =
{
- .wait = sam_wait,
- .enumerate = sam_enumerate,
.ep0configure = sam_ep0configure,
.epalloc = sam_epalloc,
.epfree = sam_epfree,
@@ -407,6 +406,14 @@ static struct sam_ohci_s g_usbhost =
},
};
+/* This is the connection/enumeration interact */
+
+static struct usbhost_connection_s g_usbconn =
+{
+ .wait = sam_wait,
+ .enumerate = sam_enumerate,
+};
+
/* This is a free list of EDs and TD buffers */
static struct sam_list_s *g_edfree; /* List of unused EDs */
@@ -1630,8 +1637,8 @@ static int sam_ohci_interrupt(int irq, FAR void *context)
* Wait for a device to be connected or disconnected to/from a root hub port.
*
* Input Parameters:
- * drvr - The USB host driver instance obtained as a parameter from the call
- * to the class create() method.
+ * conn - The USB host connection instance obtained as a parameter from the call to
+ * the USB driver initialization logic.
* connected - A pointer to an array of 3 boolean values corresponding to
* root hubs 1, 2, and 3. For each boolean value: TRUE: Wait for a device
* to be connected on the root hub; FALSE: wait for device to be
@@ -1651,9 +1658,10 @@ static int sam_ohci_interrupt(int irq, FAR void *context)
*
*******************************************************************************/
-static int sam_wait(FAR struct usbhost_driver_s *drvr, FAR const bool *connected)
+static int sam_wait(FAR struct usbhost_connection_s *conn,
+ FAR const bool *connected)
{
- struct sam_ohci_s *priv = (struct sam_ohci_s *)drvr;
+ struct sam_ohci_s *priv = &g_usbhost;
irqstate_t flags;
int rhpndx;
@@ -1707,8 +1715,8 @@ static int sam_wait(FAR struct usbhost_driver_s *drvr, FAR const bool *connected
* charge of the sequence of operations.
*
* Input Parameters:
- * drvr - The USB host driver instance obtained as a parameter from the call to
- * the class create() method.
+ * conn - The USB host connection instance obtained as a parameter from the call to
+ * the USB driver initialization logic.
* rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n.
*
* Returned Values:
@@ -1722,9 +1730,9 @@ static int sam_wait(FAR struct usbhost_driver_s *drvr, FAR const bool *connected
*
*******************************************************************************/
-static int sam_enumerate(FAR struct usbhost_driver_s *drvr, int rhpndx)
+static int sam_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx)
{
- struct sam_ohci_s *priv = (struct sam_ohci_s *)drvr;
+ struct sam_ohci_s *priv = &g_usbhost;
struct sam_rhport_s *rhport;
uint32_t regaddr;
@@ -2734,5 +2742,5 @@ FAR struct usbhost_driver_s *sam_ohci_initialize(int controller)
up_enable_irq(SAM_IRQ_UHPHS); /* enable USB interrupt */
uvdbg("USB OHCI Initialized\n");
- return &priv->drvr;
+ return &g_usbconn;
}
diff --git a/nuttx/arch/arm/src/sama5/sam_usbhost.h b/nuttx/arch/arm/src/sama5/sam_usbhost.h
index c64664daf..deb428ce2 100644
--- a/nuttx/arch/arm/src/sama5/sam_usbhost.h
+++ b/nuttx/arch/arm/src/sama5/sam_usbhost.h
@@ -107,8 +107,8 @@ extern "C"
*******************************************************************************/
#ifdef CONFIG_SAMA5_OHCI
-struct usbhost_driver_s;
-FAR struct usbhost_driver_s *sam_ohci_initialize(int controller);
+struct usbhost_connection_s;
+FAR struct usbhost_connection_s *sam_ohci_initialize(int controller);
#endif
/*******************************************************************************
diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfs.h b/nuttx/arch/arm/src/stm32/stm32_otgfs.h
index 8215256fd..673b88503 100644
--- a/nuttx/arch/arm/src/stm32/stm32_otgfs.h
+++ b/nuttx/arch/arm/src/stm32/stm32_otgfs.h
@@ -99,8 +99,8 @@ extern "C"
*******************************************************************************/
#ifdef CONFIG_USBHOST
-struct usbhost_driver_s;
-FAR struct usbhost_driver_s *stm32_otgfshost_initialize(int controller);
+struct usbhost_connection_s;
+FAR struct usbhost_connection_s *stm32_otgfshost_initialize(int controller);
#endif
/************************************************************************************
diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfshost.c b/nuttx/arch/arm/src/stm32/stm32_otgfshost.c
index 475cd710f..25eb2e846 100644
--- a/nuttx/arch/arm/src/stm32/stm32_otgfshost.c
+++ b/nuttx/arch/arm/src/stm32/stm32_otgfshost.c
@@ -358,8 +358,9 @@ static void stm32_txfe_enable(FAR struct stm32_usbhost_s *priv, int chidx);
/* USB host controller operations **********************************************/
-static int stm32_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected);
-static int stm32_enumerate(FAR struct usbhost_driver_s *drvr, int rhpndx);
+static int stm32_wait(FAR struct usbhost_connection_s *conn, FAR bool *connected);
+static int stm32_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx);
+
static int stm32_ep0configure(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
uint16_t maxpacketsize);
static int stm32_epalloc(FAR struct usbhost_driver_s *drvr,
@@ -406,8 +407,6 @@ static struct stm32_usbhost_s g_usbhost =
{
.drvr =
{
- .wait = stm32_wait,
- .enumerate = stm32_enumerate,
.ep0configure = stm32_ep0configure,
.epalloc = stm32_epalloc,
.epfree = stm32_epfree,
@@ -423,6 +422,14 @@ static struct stm32_usbhost_s g_usbhost =
.class = NULL,
};
+/* This is the connection/enumeration interact */
+
+static struct usbhost_connection_s g_usbconn =
+{
+ .wait = stm32_wait,
+ .enumerate = stm32_enumerate,
+};
+
/*******************************************************************************
* Public Data
*******************************************************************************/
@@ -3011,8 +3018,8 @@ static void stm32_txfe_enable(FAR struct stm32_usbhost_s *priv, int chidx)
* Wait for a device to be connected or disconneced.
*
* Input Parameters:
- * drvr - The USB host driver instance obtained as a parameter from the call to
- * the class create() method.
+ * conn - The USB host connection instance obtained as a parameter from the call to
+ * the USB driver initialization logic.
* connected - A pointer to a boolean value. TRUE: Wait for device to be
* connected; FALSE: wait for device to be disconnected
*
@@ -3028,9 +3035,9 @@ static void stm32_txfe_enable(FAR struct stm32_usbhost_s *priv, int chidx)
*
*******************************************************************************/
-static int stm32_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected)
+static int stm32_wait(FAR struct usbhost_connection_s *conn, FAR bool *connected)
{
- FAR struct stm32_usbhost_s *priv = (FAR struct stm32_usbhost_s *)drvr;
+ FAR struct stm32_usbhost_s *priv = &g_usbhost;
irqstate_t flags;
/* Are we already connected? */
@@ -3064,8 +3071,8 @@ static int stm32_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected)
* charge of the sequence of operations.
*
* Input Parameters:
- * drvr - The USB host driver instance obtained as a parameter from the call to
- * the class create() method.
+ * conn - The USB host connection instance obtained as a parameter from the call to
+ * the USB driver initialization logic.
* rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n.
*
* Returned Values:
@@ -3079,9 +3086,9 @@ static int stm32_wait(FAR struct usbhost_driver_s *drvr, FAR bool *connected)
*
*******************************************************************************/
-static int stm32_enumerate(FAR struct usbhost_driver_s *drvr, int rhpndx)
+static int stm32_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx)
{
- struct stm32_usbhost_s *priv = (struct stm32_usbhost_s *)drvr;
+ FAR struct stm32_usbhost_s *priv = &g_usbhost;
uint32_t regval;
int chidx;
int ret;
@@ -4222,7 +4229,7 @@ static inline int stm32_hw_initialize(FAR struct stm32_usbhost_s *priv)
*
*******************************************************************************/
-FAR struct usbhost_driver_s *stm32_otgfshost_initialize(int controller)
+FAR struct usbhost_connection_s *stm32_otgfshost_initialize(int controller)
{
/* At present, there is only support for a single OTG FS host. Hence it is
* pre-allocated as g_usbhost. However, in most code, the private data
@@ -4296,7 +4303,7 @@ FAR struct usbhost_driver_s *stm32_otgfshost_initialize(int controller)
/* Enable interrupts at the interrupt controller */
up_enable_irq(STM32_IRQ_OTGFS);
- return &priv->drvr;
+ return &g_usbconn;
}
#endif /* CONFIG_USBHOST && CONFIG_STM32_OTGFS */
diff --git a/nuttx/configs/cloudctrl/src/up_usb.c b/nuttx/configs/cloudctrl/src/up_usb.c
index 2407285c5..2ef928c14 100644
--- a/nuttx/configs/cloudctrl/src/up_usb.c
+++ b/nuttx/configs/cloudctrl/src/up_usb.c
@@ -83,7 +83,7 @@
************************************************************************************/
#ifdef CONFIG_USBHOST
-static struct usbhost_driver_s *g_drvr;
+static struct usbhost_connection_s *g_usbconn;
#endif
/************************************************************************************
@@ -109,7 +109,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Wait for the device to change state */
- ret = DRVR_WAIT(g_drvr, &connected);
+ ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
@@ -121,7 +121,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(g_drvr, 0);
+ (void)CONN_ENUMERATE(g_usbconn, 0);
}
}
@@ -187,8 +187,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n");
- g_drvr = stm32_otgfshost_initialize(0);
- if (g_drvr)
+ g_usbconn = stm32_otgfshost_initialize(0);
+ if (g_usbconn)
{
/* Start a thread to handle device connection. */
diff --git a/nuttx/configs/mikroe-stm32f4/src/up_usb.c b/nuttx/configs/mikroe-stm32f4/src/up_usb.c
index cb94e5cbe..967da72fb 100644
--- a/nuttx/configs/mikroe-stm32f4/src/up_usb.c
+++ b/nuttx/configs/mikroe-stm32f4/src/up_usb.c
@@ -82,7 +82,7 @@
************************************************************************************/
#ifdef CONFIG_USBHOST
-static struct usbhost_driver_s *g_drvr;
+static struct usbhost_connection_s *g_usbconn;
#endif
/************************************************************************************
@@ -108,7 +108,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Wait for the device to change state */
- ret = DRVR_WAIT(g_drvr, &connected);
+ ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
@@ -120,7 +120,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(g_drvr, 0);
+ (void)CONN_ENUMERATE(g_usbconn, 0);
}
}
@@ -186,8 +186,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n");
- g_drvr = stm32_otgfshost_initialize(0);
- if (g_drvr)
+ g_usbconn = stm32_otgfshost_initialize(0);
+ if (g_usbconn)
{
/* Start a thread to handle device connection. */
diff --git a/nuttx/configs/olimex-lpc1766stk/src/up_nsh.c b/nuttx/configs/olimex-lpc1766stk/src/up_nsh.c
index e893ba27e..d74ec7c8a 100644
--- a/nuttx/configs/olimex-lpc1766stk/src/up_nsh.c
+++ b/nuttx/configs/olimex-lpc1766stk/src/up_nsh.c
@@ -143,7 +143,7 @@
****************************************************************************/
#ifdef NSH_HAVEUSBHOST
-static struct usbhost_driver_s *g_drvr;
+static struct usbhost_connection_s *g_usbconn;
#endif
/****************************************************************************
@@ -169,7 +169,7 @@ static int nsh_waiter(int argc, char *argv[])
{
/* Wait for the device to change state */
- ret = DRVR_WAIT(g_drvr, &connected);
+ ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
@@ -181,7 +181,7 @@ static int nsh_waiter(int argc, char *argv[])
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(g_drvr, 0);
+ (void)CONN_ENUMERATE(g_usbconn, 0);
}
}
@@ -279,8 +279,8 @@ static int nsh_usbhostinitialize(void)
/* Then get an instance of the USB host interface */
message("nsh_usbhostinitialize: Initialize USB host\n");
- g_drvr = usbhost_initialize(0);
- if (g_drvr)
+ g_usbconn = usbhost_initialize(0);
+ if (g_usbconn)
{
/* Start a thread to handle device connection. */
diff --git a/nuttx/configs/open1788/src/lpc17_nsh.c b/nuttx/configs/open1788/src/lpc17_nsh.c
index fa6e086ed..a1899501e 100644
--- a/nuttx/configs/open1788/src/lpc17_nsh.c
+++ b/nuttx/configs/open1788/src/lpc17_nsh.c
@@ -164,7 +164,7 @@
****************************************************************************/
#ifdef NSH_HAVE_USBHOST
-static struct usbhost_driver_s *g_drvr;
+static struct usbhost_connection_s *g_usbconn;
#endif
#ifdef NSH_HAVE_MMCSD
static FAR struct sdio_dev_s *g_sdiodev;
@@ -193,7 +193,7 @@ static int nsh_waiter(int argc, char *argv[])
{
/* Wait for the device to change state */
- ret = DRVR_WAIT(g_drvr, &connected);
+ ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
@@ -205,7 +205,7 @@ static int nsh_waiter(int argc, char *argv[])
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(g_drvr, 0);
+ (void)CONN_ENUMERATE(g_usbconn, 0);
}
}
@@ -336,8 +336,8 @@ static int nsh_usbhostinitialize(void)
/* Then get an instance of the USB host interface */
message("nsh_usbhostinitialize: Initialize USB host\n");
- g_drvr = usbhost_initialize(0);
- if (g_drvr)
+ g_usbconn = usbhost_initialize(0);
+ if (g_usbconn)
{
/* Start a thread to handle device connection. */
diff --git a/nuttx/configs/pic32-starterkit/src/up_nsh.c b/nuttx/configs/pic32-starterkit/src/up_nsh.c
index 7c8e21412..f0731b8f4 100644
--- a/nuttx/configs/pic32-starterkit/src/up_nsh.c
+++ b/nuttx/configs/pic32-starterkit/src/up_nsh.c
@@ -171,7 +171,7 @@
****************************************************************************/
#ifdef NSH_HAVEUSBHOST
-static struct usbhost_driver_s *g_drvr;
+static struct usbhost_connection_s *g_usbconn;
#endif
/****************************************************************************
@@ -197,7 +197,7 @@ static int nsh_waiter(int argc, char *argv[])
{
/* Wait for the device to change state */
- ret = DRVR_WAIT(g_drvr, &connected);
+ ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
@@ -209,7 +209,7 @@ static int nsh_waiter(int argc, char *argv[])
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(g_drvr, 0);
+ (void)CONN_ENUMERATE(g_usbconn, 0);
}
}
@@ -300,8 +300,8 @@ static int nsh_usbhostinitialize(void)
/* Then get an instance of the USB host interface */
message("nsh_usbhostinitialize: Initialize USB host\n");
- g_drvr = usbhost_initialize(0);
- if (g_drvr)
+ g_usbconn = usbhost_initialize(0);
+ if (g_usbconn)
{
/* Start a thread to handle device connection. */
diff --git a/nuttx/configs/pic32mx7mmb/src/up_nsh.c b/nuttx/configs/pic32mx7mmb/src/up_nsh.c
index 5e59af564..5647702fc 100644
--- a/nuttx/configs/pic32mx7mmb/src/up_nsh.c
+++ b/nuttx/configs/pic32mx7mmb/src/up_nsh.c
@@ -170,7 +170,7 @@
****************************************************************************/
#ifdef NSH_HAVEUSBHOST
-static struct usbhost_driver_s *g_drvr;
+static struct usbhost_connection_s *g_usbconn;
#endif
/****************************************************************************
@@ -196,7 +196,7 @@ static int nsh_waiter(int argc, char *argv[])
{
/* Wait for the device to change state */
- ret = DRVR_WAIT(g_drvr, &connected);
+ ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
@@ -208,7 +208,7 @@ static int nsh_waiter(int argc, char *argv[])
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(g_drvr, 0);
+ (void)CONN_ENUMERATE(g_usbconn, 0);
}
}
@@ -308,8 +308,8 @@ static int nsh_usbhostinitialize(void)
/* Then get an instance of the USB host interface */
message("nsh_usbhostinitialize: Initialize USB host\n");
- g_drvr = usbhost_initialize(0);
- if (g_drvr)
+ g_usbconn = usbhost_initialize(0);
+ if (g_usbconn)
{
/* Start a thread to handle device connection. */
diff --git a/nuttx/configs/sama5d3x-ek/src/sam_usb.c b/nuttx/configs/sama5d3x-ek/src/sam_usb.c
index 3ab5d3c39..56348c2cf 100644
--- a/nuttx/configs/sama5d3x-ek/src/sam_usb.c
+++ b/nuttx/configs/sama5d3x-ek/src/sam_usb.c
@@ -77,10 +77,10 @@
/* Retained device driver handles */
#ifdef CONFIG_SAMA5_OHCI
-static struct usbhost_driver_s *g_ohci;
+static struct usbhost_connection_s *g_ohciconn;
#endif
#ifdef CONFIG_SAMA5_EHCI
-static struct usbhost_driver_s *g_ehci;
+static struct usbhost_connection_s *g_ehciconn;
#endif
/************************************************************************************
@@ -96,7 +96,7 @@ static struct usbhost_driver_s *g_ehci;
************************************************************************************/
#if HAVE_USBHOST
-static int usbhost_waiter(struct usbhost_driver_s *dev)
+static int usbhost_waiter(struct usbhost_connection_s *dev)
{
bool connected[SAM_USBHOST_NRHPORT] = {false, false, false};
int rhpndx;
@@ -106,7 +106,7 @@ static int usbhost_waiter(struct usbhost_driver_s *dev)
{
/* Wait for the device to change state */
- rhpndx = DRVR_WAIT(dev, connected);
+ rhpndx = CONN_WAIT(dev, connected);
DEBUGASSERT(rhpndx >= 0 && rhpndx < SAM_USBHOST_NRHPORT);
connected[rhpndx] = !connected[rhpndx];
@@ -120,7 +120,7 @@ static int usbhost_waiter(struct usbhost_driver_s *dev)
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(dev, rhpndx);
+ (void)CONN_ENUMERATE(dev, rhpndx);
}
}
@@ -141,7 +141,7 @@ static int usbhost_waiter(struct usbhost_driver_s *dev)
#ifdef CONFIG_SAMA5_OHCI
static int ohci_waiter(int argc, char *argv[])
{
- return usbhost_waiter(g_ohci);
+ return usbhost_waiter(g_ohciconn);
}
#endif
@@ -156,7 +156,7 @@ static int ohci_waiter(int argc, char *argv[])
#ifdef CONFIG_SAMA5_EHCI
static int ehci_waiter(int argc, char *argv[])
{
- return usbhost_waiter(g_ehci);
+ return usbhost_waiter(g_ehciconn);
}
#endif
@@ -287,8 +287,8 @@ int sam_usbhost_initialize(void)
#ifdef CONFIG_SAMA5_OHCI
/* Get an instance of the USB OHCI interface */
- g_ohci = sam_ohci_initialize(0);
- if (!g_ohci)
+ g_ohciconn = sam_ohci_initialize(0);
+ if (!g_ohciconn)
{
udbg("ERROR: sam_ohci_initialize failed\n");
return -ENODEV;
@@ -308,8 +308,8 @@ int sam_usbhost_initialize(void)
#ifdef CONFIG_SAMA5_EHCI
/* Get an instance of the USB EHCI interface */
- g_ehci = sam_ehci_initialize(0);
- if (!g_ehci)
+ g_ehciconn = sam_ehci_initialize(0);
+ if (!g_ehciconn)
{
udbg("ERROR: sam_ehci_initialize failed\n");
return -ENODEV;
diff --git a/nuttx/configs/shenzhou/src/up_usb.c b/nuttx/configs/shenzhou/src/up_usb.c
index 88f6d96ba..95e3a3c39 100644
--- a/nuttx/configs/shenzhou/src/up_usb.c
+++ b/nuttx/configs/shenzhou/src/up_usb.c
@@ -82,7 +82,7 @@
************************************************************************************/
#ifdef CONFIG_USBHOST
-static struct usbhost_driver_s *g_drvr;
+static struct usbhost_connection_s *g_usbconn;
#endif
/************************************************************************************
@@ -108,7 +108,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Wait for the device to change state */
- ret = DRVR_WAIT(g_drvr, &connected);
+ ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
@@ -120,7 +120,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(g_drvr, 0);
+ (void)CONN_ENUMERATE(g_usbconn, 0);
}
}
@@ -186,8 +186,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n");
- g_drvr = stm32_otgfshost_initialize(0);
- if (g_drvr)
+ g_usbconn = stm32_otgfshost_initialize(0);
+ if (g_usbconn)
{
/* Start a thread to handle device connection. */
diff --git a/nuttx/configs/stm3220g-eval/src/up_usb.c b/nuttx/configs/stm3220g-eval/src/up_usb.c
index 4de02df96..72187d009 100644
--- a/nuttx/configs/stm3220g-eval/src/up_usb.c
+++ b/nuttx/configs/stm3220g-eval/src/up_usb.c
@@ -82,7 +82,7 @@
************************************************************************************/
#ifdef CONFIG_USBHOST
-static struct usbhost_driver_s *g_drvr;
+static struct usbhost_connection_s *g_usbconn;
#endif
/************************************************************************************
@@ -108,7 +108,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Wait for the device to change state */
- ret = DRVR_WAIT(g_drvr, &connected);
+ ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
@@ -120,7 +120,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(g_drvr, 0);
+ (void)CONN_ENUMERATE(g_usbconn, 0);
}
}
@@ -186,8 +186,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n");
- g_drvr = stm32_otgfshost_initialize(0);
- if (g_drvr)
+ g_usbconn = stm32_otgfshost_initialize(0);
+ if (g_usbconn)
{
/* Start a thread to handle device connection. */
diff --git a/nuttx/configs/stm3240g-eval/src/up_usb.c b/nuttx/configs/stm3240g-eval/src/up_usb.c
index c69a017bb..d27ac3735 100644
--- a/nuttx/configs/stm3240g-eval/src/up_usb.c
+++ b/nuttx/configs/stm3240g-eval/src/up_usb.c
@@ -82,7 +82,7 @@
************************************************************************************/
#ifdef CONFIG_USBHOST
-static struct usbhost_driver_s *g_drvr;
+static struct usbhost_connection_s *g_usbconn;
#endif
/************************************************************************************
@@ -108,7 +108,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Wait for the device to change state */
- ret = DRVR_WAIT(g_drvr, &connected);
+ ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
@@ -120,7 +120,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(g_drvr, 0);
+ (void)CONN_ENUMERATE(g_usbconn, 0);
}
}
@@ -186,8 +186,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n");
- g_drvr = stm32_otgfshost_initialize(0);
- if (g_drvr)
+ g_usbconn = stm32_otgfshost_initialize(0);
+ if (g_usbconn)
{
/* Start a thread to handle device connection. */
diff --git a/nuttx/configs/stm32f4discovery/src/up_usb.c b/nuttx/configs/stm32f4discovery/src/up_usb.c
index 166f4e7a9..2ac9b6271 100644
--- a/nuttx/configs/stm32f4discovery/src/up_usb.c
+++ b/nuttx/configs/stm32f4discovery/src/up_usb.c
@@ -82,7 +82,7 @@
************************************************************************************/
#ifdef CONFIG_USBHOST
-static struct usbhost_driver_s *g_drvr;
+static struct usbhost_connection_s *g_usbconn;
#endif
/************************************************************************************
@@ -108,7 +108,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Wait for the device to change state */
- ret = DRVR_WAIT(g_drvr, &connected);
+ ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
@@ -120,7 +120,7 @@ static int usbhost_waiter(int argc, char *argv[])
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(g_drvr, 0);
+ (void)CONN_ENUMERATE(g_usbconn, 0);
}
}
@@ -186,8 +186,8 @@ int stm32_usbhost_initialize(void)
/* Then get an instance of the USB host interface */
uvdbg("Initialize USB host\n");
- g_drvr = stm32_otgfshost_initialize(0);
- if (g_drvr)
+ g_usbconn = stm32_otgfshost_initialize(0);
+ if (g_usbconn)
{
/* Start a thread to handle device connection. */
diff --git a/nuttx/configs/sure-pic32mx/src/pic32mx_nsh.c b/nuttx/configs/sure-pic32mx/src/pic32mx_nsh.c
index b9ea90dba..f36830fcb 100644
--- a/nuttx/configs/sure-pic32mx/src/pic32mx_nsh.c
+++ b/nuttx/configs/sure-pic32mx/src/pic32mx_nsh.c
@@ -162,7 +162,7 @@
****************************************************************************/
#ifdef NSH_HAVE_USBHOST
-static struct usbhost_driver_s *g_drvr;
+static struct usbhost_connection_s *g_usbconn;
#endif
/****************************************************************************
@@ -188,7 +188,7 @@ static int nsh_waiter(int argc, char *argv[])
{
/* Wait for the device to change state */
- ret = DRVR_WAIT(g_drvr, &connected);
+ ret = CONN_WAIT(g_usbconn, &connected);
DEBUGASSERT(ret == OK);
connected = !connected;
@@ -200,7 +200,7 @@ static int nsh_waiter(int argc, char *argv[])
{
/* Yes.. enumerate the newly connected device */
- (void)DRVR_ENUMERATE(g_drvr, 0);
+ (void)CONN_ENUMERATE(g_usbconn, 0);
}
}
@@ -300,8 +300,8 @@ static int nsh_usbhostinitialize(void)
/* Then get an instance of the USB host interface */
message("nsh_usbhostinitialize: Initialize USB host\n");
- g_drvr = usbhost_initialize(0);
- if (g_drvr)
+ g_usbconn = usbhost_initialize(0);
+ if (g_usbconn)
{
/* Start a thread to handle device connection. */
diff --git a/nuttx/include/nuttx/usb/usbhost.h b/nuttx/include/nuttx/usb/usbhost.h
index d357e0b9b..937bc7769 100644
--- a/nuttx/include/nuttx/usb/usbhost.h
+++ b/nuttx/include/nuttx/usb/usbhost.h
@@ -152,14 +152,14 @@
#define CLASS_DISCONNECTED(class) ((class)->disconnected(class))
/*******************************************************************************
- * Name: DRVR_WAIT
+ * Name: CONN_WAIT
*
* Description:
* Wait for a device to be connected or disconnected to/from a root hub port.
*
* Input Parameters:
- * drvr - The USB host driver instance obtained as a parameter from the call
- * to the class create() method.
+ * conn - The USB host connection instance obtained as a parameter from the call to
+ * the USB driver initialization logic.
* connected - A pointer to an array of n boolean values corresponding to
* root hubs 1 through n. For each boolean value: TRUE: Wait for a device
* to be connected on the root hub; FALSE: wait for device to be
@@ -178,10 +178,10 @@
*
*******************************************************************************/
-#define DRVR_WAIT(drvr, connected) ((drvr)->wait(drvr,connected))
+#define CONN_WAIT(conn, connected) ((conn)->wait(conn,connected))
/************************************************************************************
- * Name: DRVR_ENUMERATE
+ * Name: CONN_ENUMERATE
*
* Description:
* Enumerate the connected device. As part of this enumeration process,
@@ -194,8 +194,8 @@
* charge of the sequence of operations.
*
* Input Parameters:
- * drvr - The USB host driver instance obtained as a parameter from the call to
- * the class create() method.
+ * conn - The USB host connection instance obtained as a parameter from the call to
+ * the USB driver initialization logic.
* rphndx - Root hub port index. 0-(n-1) corresponds to root hub port 1-n.
*
* Returned Values:
@@ -207,7 +207,7 @@
*
************************************************************************************/
-#define DRVR_ENUMERATE(drvr,rhpndx) ((drvr)->enumerate(drvr,rhpndx))
+#define CONN_ENUMERATE(conn,rhpndx) ((conn)->enumerate(conn,rhpndx))
/************************************************************************************
* Name: DRVR_EP0CONFIGURE
@@ -586,15 +586,16 @@ struct usbhost_epdesc_s
typedef FAR void *usbhost_ep_t;
-/* struct usbhost_driver_s provides access to the USB host driver from the
- * USB host class implementation.
+/* struct usbhost_connection_s provides as interface between platform-specific
+ * connection monitoring and the USB host driver connectin and enumeration
+ * logic.
*/
-struct usbhost_driver_s
+struct usbhost_connection_s
{
/* Wait for a device to connect or disconnect. */
- int (*wait)(FAR struct usbhost_driver_s *drvr, FAR const bool *connected);
+ int (*wait)(FAR struct usbhost_connection_s *drvr, FAR const bool *connected);
/* Enumerate the device connected on a root hub port. As part of this
* enumeration process, the driver will (1) get the device's configuration
@@ -606,8 +607,15 @@ struct usbhost_driver_s
* in charge of the sequence of operations.
*/
- int (*enumerate)(FAR struct usbhost_driver_s *drvr, int rhpndx);
+ int (*enumerate)(FAR struct usbhost_connection_s *drvr, int rhpndx);
+};
+
+/* struct usbhost_driver_s provides access to the USB host driver from the
+ * USB host class implementation.
+ */
+struct usbhost_driver_s
+{
/* Configure endpoint 0. This method is normally used internally by the
* enumerate() method but is made available at the interface to support
* an external implementation of the enumeration logic.