mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
USB HUB: Update all USB host connection waiter application threads to use the the new connection interface
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/cloudctrl/src/stm32_usb.c
|
* configs/cloudctrl/src/stm32_usb.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
* Darcy Gong <darcy.gong@gmail.com>
|
* Darcy Gong <darcy.gong@gmail.com>
|
||||||
*
|
*
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev.h>
|
#include <nuttx/usb/usbdev.h>
|
||||||
@@ -100,27 +101,23 @@ static struct usbhost_connection_s *g_usbconn;
|
|||||||
#ifdef CONFIG_USBHOST
|
#ifdef CONFIG_USBHOST
|
||||||
static int usbhost_waiter(int argc, char *argv[])
|
static int usbhost_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
uvdbg("Running\n");
|
uvdbg("Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
uvdbg("%s\n", connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/mikroe_stm32f4/src/stm32_usb.c
|
* configs/mikroe_stm32f4/src/stm32_usb.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev.h>
|
#include <nuttx/usb/usbdev.h>
|
||||||
@@ -99,27 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
|
|||||||
#ifdef CONFIG_USBHOST
|
#ifdef CONFIG_USBHOST
|
||||||
static int usbhost_waiter(int argc, char *argv[])
|
static int usbhost_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
uvdbg("Running\n");
|
uvdbg("Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
uvdbg("%s\n", connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev.h>
|
#include <nuttx/usb/usbdev.h>
|
||||||
@@ -98,28 +99,23 @@ static struct usbhost_connection_s *g_usbconn;
|
|||||||
#ifdef CONFIG_USBHOST
|
#ifdef CONFIG_USBHOST
|
||||||
static int usbhost_waiter(int argc, char *argv[])
|
static int usbhost_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
uvdbg("Running\n");
|
uvdbg("Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
|
||||||
UNUSED(ret);
|
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
uvdbg("%s\n", connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
@@ -170,28 +171,23 @@ static FAR struct sdio_dev_s *g_sdiodev;
|
|||||||
#ifdef NSH_HAVE_USBHOST
|
#ifdef NSH_HAVE_USBHOST
|
||||||
static int nsh_waiter(int argc, char *argv[])
|
static int nsh_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
syslog(LOG_INFO, "nsh_waiter: Running\n");
|
syslog(LOG_INFO, "nsh_waiter: Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
syslog(LOG_INFO, "nsh_waiter: %s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
syslog(LOG_INFO, "nsh_waiter: %s\n",
|
|
||||||
connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
@@ -173,28 +174,23 @@ static struct usbhost_connection_s *g_usbconn;
|
|||||||
#ifdef NSH_HAVEUSBHOST
|
#ifdef NSH_HAVEUSBHOST
|
||||||
static int nsh_waiter(int argc, char *argv[])
|
static int nsh_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
syslog(LOG_INFO, "nsh_waiter: Running\n");
|
syslog(LOG_INFO, "nsh_waiter: Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
syslog(LOG_INFO, "nsh_waiter: %s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
syslog(LOG_INFO, "nsh_waiter: %s\n",
|
|
||||||
connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
@@ -172,28 +173,23 @@ static struct usbhost_connection_s *g_usbconn;
|
|||||||
#ifdef NSH_HAVEUSBHOST
|
#ifdef NSH_HAVEUSBHOST
|
||||||
static int nsh_waiter(int argc, char *argv[])
|
static int nsh_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
syslog(LOG_INFO, "nsh_waiter: Running\n");
|
syslog(LOG_INFO, "nsh_waiter: Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
syslog(LOG_INFO, "nsh_waiter: %s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
syslog(LOG_INFO, "nsh_waiter: %s\n",
|
|
||||||
connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/sama5d3-xplained/src/sam_usb.c
|
* configs/sama5d3-xplained/src/sam_usb.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -112,35 +112,23 @@ static int usbhost_waiter(struct usbhost_connection_s *dev, const char *hcistr)
|
|||||||
static int usbhost_waiter(struct usbhost_connection_s *dev)
|
static int usbhost_waiter(struct usbhost_connection_s *dev)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bool connected[SAM_OHCI_NRHPORT] = {false, false, false};
|
struct usbhost_hubport_s *hport;
|
||||||
int rhpndx;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
uvdbg("%s Waiter Running\n", hcistr);
|
uvdbg("Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
rhpndx = CONN_WAIT(dev, connected);
|
DEBUGVERIFY(CONN_WAIT(dev, &hport));
|
||||||
DEBUGASSERT(rhpndx >= 0 && rhpndx < SAM_OHCI_NRHPORT);
|
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected[rhpndx] = !connected[rhpndx];
|
|
||||||
|
|
||||||
uvdbg("%s RHport%d %s\n",
|
|
||||||
hcistr, rhpndx + 1, connected[rhpndx] ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected[rhpndx])
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
ret = CONN_ENUMERATE(dev, rhpndx);
|
(void)CONN_ENUMERATE(dev, hport);
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
uvdbg("%s RHport%d CONN_ENUMERATE failed: %d\n", hcistr, rhpndx+1, ret);
|
|
||||||
connected[rhpndx] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,35 +112,23 @@ static int usbhost_waiter(struct usbhost_connection_s *dev, const char *hcistr)
|
|||||||
static int usbhost_waiter(struct usbhost_connection_s *dev)
|
static int usbhost_waiter(struct usbhost_connection_s *dev)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bool connected[SAM_OHCI_NRHPORT] = {false, false, false};
|
struct usbhost_hubport_s *hport;
|
||||||
int rhpndx;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
uvdbg("%s Waiter Running\n", hcistr);
|
uvdbg("Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
rhpndx = CONN_WAIT(dev, connected);
|
DEBUGVERIFY(CONN_WAIT(dev, &hport));
|
||||||
DEBUGASSERT(rhpndx >= 0 && rhpndx < SAM_OHCI_NRHPORT);
|
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected[rhpndx] = !connected[rhpndx];
|
|
||||||
|
|
||||||
uvdbg("%s RHport%d %s\n",
|
|
||||||
hcistr, rhpndx + 1, connected[rhpndx] ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected[rhpndx])
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
ret = CONN_ENUMERATE(dev, rhpndx);
|
(void)CONN_ENUMERATE(dev, hport);
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
uvdbg("%s RHport%d CONN_ENUMERATE failed: %d\n", hcistr, rhpndx+1, ret);
|
|
||||||
connected[rhpndx] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,35 +112,23 @@ static int usbhost_waiter(struct usbhost_connection_s *dev, const char *hcistr)
|
|||||||
static int usbhost_waiter(struct usbhost_connection_s *dev)
|
static int usbhost_waiter(struct usbhost_connection_s *dev)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bool connected[SAM_OHCI_NRHPORT] = {false, false, false};
|
struct usbhost_hubport_s *hport;
|
||||||
int rhpndx;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
uvdbg("%s Waiter Running\n", hcistr);
|
uvdbg("Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
rhpndx = CONN_WAIT(dev, connected);
|
DEBUGVERIFY(CONN_WAIT(dev, &hport));
|
||||||
DEBUGASSERT(rhpndx >= 0 && rhpndx < SAM_OHCI_NRHPORT);
|
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected[rhpndx] = !connected[rhpndx];
|
|
||||||
|
|
||||||
uvdbg("%s RHport%d %s\n",
|
|
||||||
hcistr, rhpndx + 1, connected[rhpndx] ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected[rhpndx])
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
ret = CONN_ENUMERATE(dev, rhpndx);
|
(void)CONN_ENUMERATE(dev, hport);
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
uvdbg("%s RHport%d CONN_ENUMERATE failed: %d\n", hcistr, rhpndx+1, ret);
|
|
||||||
connected[rhpndx] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/shenzhou/src/stm32_usb.c
|
* configs/shenzhou/src/stm32_usb.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev.h>
|
#include <nuttx/usb/usbdev.h>
|
||||||
@@ -99,27 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
|
|||||||
#ifdef CONFIG_USBHOST
|
#ifdef CONFIG_USBHOST
|
||||||
static int usbhost_waiter(int argc, char *argv[])
|
static int usbhost_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
uvdbg("Running\n");
|
uvdbg("Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
uvdbg("%s\n", connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/stm3220g-eval/src/stm32_usb.c
|
* configs/stm3220g-eval/src/stm32_usb.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev.h>
|
#include <nuttx/usb/usbdev.h>
|
||||||
@@ -99,27 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
|
|||||||
#ifdef CONFIG_USBHOST
|
#ifdef CONFIG_USBHOST
|
||||||
static int usbhost_waiter(int argc, char *argv[])
|
static int usbhost_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
uvdbg("Running\n");
|
uvdbg("Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
uvdbg("%s\n", connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/stm3240g-eval/src/stm32_usbdev.c
|
* configs/stm3240g-eval/src/stm32_usbdev.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev.h>
|
#include <nuttx/usb/usbdev.h>
|
||||||
@@ -99,27 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
|
|||||||
#ifdef CONFIG_USBHOST
|
#ifdef CONFIG_USBHOST
|
||||||
static int usbhost_waiter(int argc, char *argv[])
|
static int usbhost_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
uvdbg("Running\n");
|
uvdbg("Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
uvdbg("%s\n", connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev.h>
|
#include <nuttx/usb/usbdev.h>
|
||||||
@@ -99,28 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
|
|||||||
#ifdef CONFIG_USBHOST
|
#ifdef CONFIG_USBHOST
|
||||||
static int usbhost_waiter(int argc, char *argv[])
|
static int usbhost_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
uvdbg("Running\n");
|
uvdbg("Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
|
||||||
UNUSED(ret);
|
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
uvdbg("%s\n", connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/stm32f4discovery/src/stm32_usb.c
|
* configs/stm32f4discovery/src/stm32_usb.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012-2013, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/usb/usbdev.h>
|
#include <nuttx/usb/usbdev.h>
|
||||||
@@ -99,28 +100,23 @@ static struct usbhost_connection_s *g_usbconn;
|
|||||||
#ifdef CONFIG_USBHOST
|
#ifdef CONFIG_USBHOST
|
||||||
static int usbhost_waiter(int argc, char *argv[])
|
static int usbhost_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
uvdbg("Running\n");
|
uvdbg("Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
uvdbg("%s\n", hport->connected ? "connected" : "disconnected");
|
||||||
UNUSED(ret);
|
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
uvdbg("%s\n", connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* config/sure-pic32mx/src/pic32mx_nsh.c
|
* config/sure-pic32mx/src/pic32mx_nsh.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <nuttx/board.h>
|
#include <nuttx/board.h>
|
||||||
#include <nuttx/spi/spi.h>
|
#include <nuttx/spi/spi.h>
|
||||||
@@ -165,28 +166,23 @@ static struct usbhost_connection_s *g_usbconn;
|
|||||||
#ifdef NSH_HAVE_USBHOST
|
#ifdef NSH_HAVE_USBHOST
|
||||||
static int nsh_waiter(int argc, char *argv[])
|
static int nsh_waiter(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
bool connected = false;
|
struct usbhost_hubport_s *hport;
|
||||||
int ret;
|
|
||||||
|
|
||||||
syslog(LOG_INFO, "nsh_waiter: Running\n");
|
syslog(LOG_INFO, "nsh_waiter: Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = CONN_WAIT(g_usbconn, &connected);
|
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
|
||||||
DEBUGASSERT(ret == OK);
|
syslog(LOG_INFO, "nsh_waiter: %s\n", hport->connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
connected = !connected;
|
|
||||||
syslog(LOG_INFO, "nsh_waiter: %s\n",
|
|
||||||
connected ? "connected" : "disconnected");
|
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
if (connected)
|
if (hport->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. enumerate the newly connected device */
|
/* Yes.. enumerate the newly connected device */
|
||||||
|
|
||||||
(void)CONN_ENUMERATE(g_usbconn, 0);
|
(void)CONN_ENUMERATE(g_usbconn, hport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user