mirror of
https://github.com/apache/nuttx.git
synced 2026-09-27 18:58:27 +08:00
Slightly improved delay logic for the USB host
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5064 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
@@ -317,7 +318,7 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
|
||||
|
||||
DEBUGASSERT(drvr && class);
|
||||
|
||||
/* Allocate TD buffers for use in this function. We will need two:
|
||||
/* Allocate descriptor buffers for use in this function. We will need two:
|
||||
* One for the request and one for the data buffer.
|
||||
*/
|
||||
|
||||
@@ -400,7 +401,7 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
|
||||
udbg("ERROR: SETADDRESS DRVR_CTRLOUT returned %d\n", ret);
|
||||
goto errout;
|
||||
}
|
||||
up_mdelay(2);
|
||||
usleep(2*1000);
|
||||
|
||||
/* Modify control pipe with the provided USB device address */
|
||||
|
||||
@@ -461,9 +462,9 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Free the TD that we were using for the request buffer. It is not needed
|
||||
* further here but it may be needed by the class driver during its connection
|
||||
* operations.
|
||||
/* Free the descriptor buffer that we were using for the request buffer.
|
||||
* It is not needed further here but it may be needed by the class driver
|
||||
* during its connection operations.
|
||||
*/
|
||||
|
||||
DRVR_FREE(drvr, (uint8_t*)ctrlreq);
|
||||
@@ -488,9 +489,9 @@ int usbhost_enumerate(FAR struct usbhost_driver_s *drvr, uint8_t funcaddr,
|
||||
}
|
||||
}
|
||||
|
||||
/* Some devices may require this delay before initialization */
|
||||
/* Some devices may require some delay before initialization */
|
||||
|
||||
up_mdelay(100);
|
||||
usleep(100*1000);
|
||||
|
||||
/* Parse the configuration descriptor and bind to the class instance for the
|
||||
* device. This needs to be the last thing done because the class driver
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <semaphore.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
@@ -724,6 +725,7 @@ static inline int usbhost_testunitready(FAR struct usbhost_state_s *priv)
|
||||
usbhost_dumpcsw((FAR struct usbmsc_csw_s *)priv->tbuffer);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1195,13 +1197,15 @@ static inline int usbhost_initvolume(FAR struct usbhost_state_s *priv)
|
||||
uvdbg("Get max LUN\n");
|
||||
ret = usbhost_maxlunreq(priv);
|
||||
|
||||
/* Wait for the unit to be ready */
|
||||
|
||||
for (retries = 0; retries < USBHOST_MAX_RETRIES && ret == OK; retries++)
|
||||
for (retries = 0; retries < USBHOST_MAX_RETRIES /* && ret == OK */; retries++)
|
||||
{
|
||||
uvdbg("Test unit ready, retries=%d\n", retries);
|
||||
|
||||
/* Send TESTUNITREADY to see the unit is ready */
|
||||
/* Wait just a bit */
|
||||
|
||||
usleep(50*1000);
|
||||
|
||||
/* Send TESTUNITREADY to see if the unit is ready */
|
||||
|
||||
ret = usbhost_testunitready(priv);
|
||||
if (ret == OK)
|
||||
|
||||
Reference in New Issue
Block a user