Handling missing RHSC interrupt
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3223 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
6ac3d377de
commit
e9c73d6e46
@ -706,6 +706,12 @@ defconfig -- This is a configuration file similar to the Linux
|
||||
USB host controller driver
|
||||
CONFIG_USBHOST
|
||||
Enables USB host support
|
||||
CONFIG_USBHOST_HAVERHSC
|
||||
Define if the hardware is able to detect a root hub status change
|
||||
when a device is inserted. If CONFIG_USBHOST_HAVERHSC is not set,
|
||||
then it is assumed that the hardware cannot detect the presence
|
||||
of a USB device and that the application must periodically attempt
|
||||
to enumerate the device.
|
||||
CONFIG_USBHOST_NPREALLOC
|
||||
Number of pre-allocated class instances
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
@ -171,6 +172,7 @@ static int nsh_waiter(int argc, char *argv[])
|
||||
message("nsh_waiter: Running\n");
|
||||
for (;;)
|
||||
{
|
||||
#ifdef CONFIG_USBHOST_HAVERHSC
|
||||
/* Wait for the device to change state */
|
||||
|
||||
ret = DRVR_WAIT(g_drvr, connected);
|
||||
@ -187,6 +189,39 @@ static int nsh_waiter(int argc, char *argv[])
|
||||
|
||||
(void)DRVR_ENUMERATE(g_drvr);
|
||||
}
|
||||
#else
|
||||
/* Is the device connected? */
|
||||
|
||||
if (connected)
|
||||
{
|
||||
/* Yes.. wait for the disconnect event */
|
||||
|
||||
ret = DRVR_WAIT(g_drvr, false);
|
||||
DEBUGASSERT(ret == OK);
|
||||
|
||||
connected = false;
|
||||
message("nsh_waiter: Not connected\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wait a bit */
|
||||
|
||||
sleep(2);
|
||||
|
||||
/* Try to enumerate the device */
|
||||
|
||||
uvdbg("nsh_usbhostinitialize: Enumerate device\n");
|
||||
ret = DRVR_ENUMERATE(g_drvr);
|
||||
if (ret != OK)
|
||||
{
|
||||
uvdbg("nsh_usbhostinitialize: Enumeration failed: %d\n", ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
message("nsh_usbhostinitialize: Connected\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Keep the compiler from complaining */
|
||||
@ -210,6 +245,7 @@ static int nsh_usbhostinitialize(void)
|
||||
|
||||
/* First, get an instance of the USB host interface */
|
||||
|
||||
message("nsh_usbhostinitialize: Initialize USB host\n");
|
||||
g_drvr = usbhost_initialize(0);
|
||||
if (g_drvr)
|
||||
{
|
||||
|
@ -225,6 +225,29 @@
|
||||
* P2[9]/USB_CONNECT/RXD2 64 USBD_CONNECT
|
||||
*/
|
||||
|
||||
#ifdef GPIO_USB_PPWR /* We can only redefine this if they have been defined */
|
||||
|
||||
/* The Olimex LPC1766-STK has 10K pull-ups on PPWR and OVRCR and a 100k
|
||||
* pull-down on PWRD so we should make sure that the outputs float.
|
||||
*/
|
||||
|
||||
# undef GPIO_USB_PPWR
|
||||
# define GPIO_USB_PPWR (GPIO_ALT2 | GPIO_FLOAT | GPIO_PORT1 | GPIO_PIN19)
|
||||
# undef GPIO_USB_OVRCR
|
||||
# define GPIO_USB_OVRCR (GPIO_ALT2 | GPIO_FLOAT | GPIO_PORT1 | GPIO_PIN27)
|
||||
# undef GPIO_USB_PWRD
|
||||
# define GPIO_USB_PWRD (GPIO_ALT2 | GPIO_FLOAT | GPIO_PORT1 | GPIO_PIN22)
|
||||
|
||||
/* In host mode (only) there are also 15K pull-downs on D+ and D- */
|
||||
|
||||
# ifdef CONFIG_USBHOST
|
||||
# undef GPIO_USB_DP
|
||||
# define GPIO_USB_DP (GPIO_ALT1 | GPIO_FLOAT | GPIO_PORT0 | GPIO_PIN29)
|
||||
# undef GPIO_USB_DM
|
||||
# define GPIO_USB_DM (GPIO_ALT1 | GPIO_FLOAT | GPIO_PORT0 | GPIO_PIN30)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Ethernet GPIO PIN SIGNAL NAME
|
||||
* -------------------------------- ---- --------------
|
||||
* P1[0]/ENET_TXD0 95 E_TXD0
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
@ -164,6 +165,7 @@ static int nsh_waiter(int argc, char *argv[])
|
||||
message("nsh_waiter: Running\n");
|
||||
for (;;)
|
||||
{
|
||||
#ifdef CONFIG_USBHOST_HAVERHSC
|
||||
/* Wait for the device to change state */
|
||||
|
||||
ret = DRVR_WAIT(g_drvr, connected);
|
||||
@ -180,6 +182,39 @@ static int nsh_waiter(int argc, char *argv[])
|
||||
|
||||
(void)DRVR_ENUMERATE(g_drvr);
|
||||
}
|
||||
#else
|
||||
/* Is the device connected? */
|
||||
|
||||
if (connected)
|
||||
{
|
||||
/* Yes.. wait for the disconnect event */
|
||||
|
||||
ret = DRVR_WAIT(g_drvr, false);
|
||||
DEBUGASSERT(ret == OK);
|
||||
|
||||
connected = false;
|
||||
message("nsh_waiter: Not connected\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Wait a bit */
|
||||
|
||||
sleep(2);
|
||||
|
||||
/* Try to enumerate the device */
|
||||
|
||||
uvdbg("nsh_usbhostinitialize: Enumerate device\n");
|
||||
ret = DRVR_ENUMERATE(g_drvr);
|
||||
if (ret != OK)
|
||||
{
|
||||
uvdbg("nsh_usbhostinitialize: Enumeration failed: %d\n", ret);
|
||||
}
|
||||
else
|
||||
{
|
||||
message("nsh_usbhostinitialize: Connected\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Keep the compiler from complaining */
|
||||
@ -263,6 +298,7 @@ static int nsh_usbhostinitialize(void)
|
||||
|
||||
/* First, get an instance of the USB host interface */
|
||||
|
||||
message("nsh_usbhostinitialize: Initialize USB host\n");
|
||||
g_drvr = usbhost_initialize(0);
|
||||
if (g_drvr)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user