mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
First debug changes for USB host
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3215 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -88,9 +88,7 @@
|
|||||||
|
|
||||||
/* CLKCTRL enable bits */
|
/* CLKCTRL enable bits */
|
||||||
|
|
||||||
#define LPC17_CLKCTRL_ENABLES (USBOTG_CLK_HOSTCLK|USBOTG_CLK_DEVCLK|\
|
#define LPC17_CLKCTRL_ENABLES (USBOTG_CLK_HOSTCLK|USBDEV_CLK_PORTSELCLK|USBOTG_CLK_AHBCLK)
|
||||||
USBOTG_CLK_I2CCLK|USBOTG_CLK_OTGCLK|\
|
|
||||||
USBOTG_CLK_AHBCLK)
|
|
||||||
|
|
||||||
/* Dump GPIO registers */
|
/* Dump GPIO registers */
|
||||||
|
|
||||||
@@ -881,8 +879,9 @@ static int lpc17_usbinterrupt(int irq, FAR void *context)
|
|||||||
|
|
||||||
intstatus = lpc17_getreg(LPC17_USBHOST_INTST);
|
intstatus = lpc17_getreg(LPC17_USBHOST_INTST);
|
||||||
intenable = lpc17_getreg(LPC17_USBHOST_INTEN);
|
intenable = lpc17_getreg(LPC17_USBHOST_INTEN);
|
||||||
intstatus &= intenable;
|
ullvdbg("INST: %08x INTEN:\n", intstatus, intenable);
|
||||||
|
|
||||||
|
intstatus &= intenable;
|
||||||
if (intstatus != 0)
|
if (intstatus != 0)
|
||||||
{
|
{
|
||||||
/* Root hub status change interrupt */
|
/* Root hub status change interrupt */
|
||||||
@@ -914,6 +913,7 @@ static int lpc17_usbinterrupt(int irq, FAR void *context)
|
|||||||
{
|
{
|
||||||
if (!priv->connected)
|
if (!priv->connected)
|
||||||
{
|
{
|
||||||
|
ullvdbg("Connected\n");
|
||||||
DEBUGASSERT(priv->rhssem.semcount <= 0);
|
DEBUGASSERT(priv->rhssem.semcount <= 0);
|
||||||
priv->tdstatus = 0;
|
priv->tdstatus = 0;
|
||||||
priv->connected = true;
|
priv->connected = true;
|
||||||
@@ -929,8 +929,9 @@ static int lpc17_usbinterrupt(int irq, FAR void *context)
|
|||||||
|
|
||||||
else if (priv->connected)
|
else if (priv->connected)
|
||||||
{
|
{
|
||||||
/* Yes.. disable interrupts */
|
/* Yes.. disable interrupts and disconnect the device */
|
||||||
|
|
||||||
|
ullvdbg("Disconnected\n");
|
||||||
lpc17_putreg(0, LPC17_USBHOST_INTEN);
|
lpc17_putreg(0, LPC17_USBHOST_INTEN);
|
||||||
priv->connected = false;
|
priv->connected = false;
|
||||||
|
|
||||||
@@ -1713,6 +1714,8 @@ FAR struct usbhost_driver_s *usbhost_initialize(int controller)
|
|||||||
/* Enable clocking on USB (USB PLL clocking was initialized in very low-
|
/* Enable clocking on USB (USB PLL clocking was initialized in very low-
|
||||||
* evel clock setup logic (see lpc17_clockconfig.c)). We do still need
|
* evel clock setup logic (see lpc17_clockconfig.c)). We do still need
|
||||||
* to set up USBOTG CLKCTRL to enable clocking.
|
* to set up USBOTG CLKCTRL to enable clocking.
|
||||||
|
*
|
||||||
|
* NOTE: The PORTSEL clock needs to be enabled only when accessing OTGSTCTRL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
lpc17_putreg(LPC17_CLKCTRL_ENABLES, LPC17_USBOTG_CLKCTRL);
|
lpc17_putreg(LPC17_CLKCTRL_ENABLES, LPC17_USBOTG_CLKCTRL);
|
||||||
@@ -1725,7 +1728,21 @@ FAR struct usbhost_driver_s *usbhost_initialize(int controller)
|
|||||||
}
|
}
|
||||||
while ((regval & LPC17_CLKCTRL_ENABLES) != LPC17_CLKCTRL_ENABLES);
|
while ((regval & LPC17_CLKCTRL_ENABLES) != LPC17_CLKCTRL_ENABLES);
|
||||||
|
|
||||||
lpc17_putreg(3, LPC17_USBOTG_STCTRL);
|
/* Set the OTG status and control register. Bits 0:1 apparently mean:
|
||||||
|
*
|
||||||
|
* 10: U1=device, U2=host
|
||||||
|
* 11: U1=host, U2=host
|
||||||
|
* 10: reserved
|
||||||
|
* 11: U1=host, U2=device
|
||||||
|
*
|
||||||
|
* NOTE: The PORTSEL clock needs to be enabled only when accessing OTGSTCTRL
|
||||||
|
*/
|
||||||
|
|
||||||
|
lpc17_putreg(1, LPC17_USBOTG_STCTRL);
|
||||||
|
|
||||||
|
/* Now we can turn off the PORTSEL clock */
|
||||||
|
|
||||||
|
lpc17_putreg((LPC17_CLKCTRL_ENABLES & ~USBDEV_CLK_PORTSELCLK), LPC17_USBOTG_CLKCTRL);
|
||||||
|
|
||||||
/* Step 3: Configure I/O pins */
|
/* Step 3: Configure I/O pins */
|
||||||
|
|
||||||
|
|||||||
@@ -161,13 +161,16 @@ static int nsh_waiter(int argc, char *argv[])
|
|||||||
bool connected = false;
|
bool connected = false;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
message("nsh_waiter: Running\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
/* Wait for the device to change state */
|
/* Wait for the device to change state */
|
||||||
|
|
||||||
ret = DRVR_WAIT(g_drvr, connected);
|
ret = DRVR_WAIT(g_drvr, connected);
|
||||||
DEBUGASSERT(ret == OK);
|
DEBUGASSERT(ret == OK);
|
||||||
|
|
||||||
connected = !connected;
|
connected = !connected;
|
||||||
|
message("nsh_waiter: %s\n", connected ? "connected" : "disconnected");
|
||||||
|
|
||||||
/* Did we just become connected? */
|
/* Did we just become connected? */
|
||||||
|
|
||||||
@@ -265,6 +268,8 @@ static int nsh_usbhostinitialize(void)
|
|||||||
{
|
{
|
||||||
/* Start a thread to handle device connection. */
|
/* Start a thread to handle device connection. */
|
||||||
|
|
||||||
|
message("nsh_usbhostinitialize: Start nsh_waiter\n");
|
||||||
|
|
||||||
#ifndef CONFIG_CUSTOM_STACK
|
#ifndef CONFIG_CUSTOM_STACK
|
||||||
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
pid = task_create("usbhost", CONFIG_USBHOST_DEFPRIO,
|
||||||
CONFIG_USBHOST_STACKSIZE,
|
CONFIG_USBHOST_STACKSIZE,
|
||||||
|
|||||||
@@ -63,6 +63,12 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Telnetd requires networking support */
|
||||||
|
|
||||||
|
#ifndef CONFIG_NET
|
||||||
|
# undef CONFIG_EXAMPLES_NSH_TELNET
|
||||||
|
#endif
|
||||||
|
|
||||||
/* One front end must be defined */
|
/* One front end must be defined */
|
||||||
|
|
||||||
#if !defined(CONFIG_EXAMPLES_NSH_CONSOLE) && !defined(CONFIG_EXAMPLES_NSH_TELNET)
|
#if !defined(CONFIG_EXAMPLES_NSH_CONSOLE) && !defined(CONFIG_EXAMPLES_NSH_TELNET)
|
||||||
|
|||||||
Reference in New Issue
Block a user