More random USB debug changes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2835 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
faa7d2112c
commit
592053890c
@ -563,7 +563,7 @@
|
||||
/* I2C Clock Low */
|
||||
|
||||
#define OTGI2C_CLKLO_SHIFT (0) /* Bits 0-7: Clock divisor high */
|
||||
#define OTGI2C_CLLO_MASK (0xff << OTGI2C_CLKLO_SHIFT)
|
||||
#define OTGI2C_CLLO_MASK (0xff << OTGI2C_CLKLO_SHIFT)
|
||||
/* Bits 8-31: Reserved */
|
||||
/* Clock control registers ***********************************************************/
|
||||
|
||||
@ -617,11 +617,17 @@
|
||||
|
||||
/* Commands *************************************************************************/
|
||||
|
||||
/* USB Command Code Register -- Command phase values */
|
||||
/* USB Command Code Register */
|
||||
|
||||
#define CMD_USBDEV_CMDWR (0x00000500)
|
||||
#define CMD_USBDEV_DATAWR (0x00000100)
|
||||
#define CMD_USBDEV_DATARD (0x00000200)
|
||||
#define CMD_USBDEV_PHASESHIFT (8) /* Bits 8-15: Command phase value */
|
||||
#define CMD_USBDEV_PHASEMASK (0xff << CMD_USBDEV_PHASESHIFT)
|
||||
# define CMD_USBDEV_DATAWR (1 << CMD_USBDEV_PHASESHIFT)
|
||||
# define CMD_USBDEV_DATARD (2 << CMD_USBDEV_PHASESHIFT)
|
||||
# define CMD_USBDEV_CMDWR (5 << CMD_USBDEV_PHASESHIFT)
|
||||
#define CMD_USBDEV_CMDSHIFT (16) /* Bits 16-23: Device command/WDATA */
|
||||
#define CMD_USBDEV_CMDMASK (0xff << CMD_USBDEV_CMDSHIFT)
|
||||
#define CMD_USBDEV_WDATASHIFT CMD_USBDEV_CMDSHIFT
|
||||
#define CMD_USBDEV_WDATAMASK CMD_USBDEV_CMDMASK
|
||||
|
||||
/* Device Commands */
|
||||
|
||||
@ -630,7 +636,7 @@
|
||||
#define CMD_USBDEV_SETMODE (0x00f3)
|
||||
#define CMD_USBDEV_READFRAMENO (0x00f5)
|
||||
#define CMD_USBDEV_READTESTREG (0x00fd)
|
||||
#define CMD_USBDEV_SETSTATUS (0x01fe)
|
||||
#define CMD_USBDEV_SETSTATUS (0x01fe) /* Bit 8 set to distingish get from set */
|
||||
#define CMD_USBDEV_GETSTATUS (0x00fe)
|
||||
#define CMD_USBDEV_GETERRORCODE (0x00ff)
|
||||
#define CMD_USBDEV_READERRORSTATUS (0x00fb)
|
||||
@ -639,7 +645,7 @@
|
||||
|
||||
#define CMD_USBDEV_EPSELECT (0x0000)
|
||||
#define CMD_USBDEV_EPSELECTCLEAR (0x0040)
|
||||
#define CMD_USBDEV_EPSETSTATUS (0x0140)
|
||||
#define CMD_USBDEV_EPSETSTATUS (0x0140) /* Bit 8 set to distingish get from selectclear */
|
||||
#define CMD_USBDEV_EPCLRBUFFER (0x00f2)
|
||||
#define CMD_USBDEV_EPVALIDATEBUFFER (0x00fa)
|
||||
|
||||
|
@ -647,6 +647,8 @@ static void lpc17_putreg(uint32_t val, uint32_t addr)
|
||||
static uint32_t lpc17_usbcmd(uint16_t cmd, uint8_t data)
|
||||
{
|
||||
irqstate_t flags;
|
||||
uint32_t cmd32;
|
||||
uint32_t data32;
|
||||
uint32_t tmp = 0;
|
||||
|
||||
/* Disable interrupt and clear CDFULL and CCEMPTY interrupt status */
|
||||
@ -654,9 +656,13 @@ static uint32_t lpc17_usbcmd(uint16_t cmd, uint8_t data)
|
||||
flags = irqsave();
|
||||
lpc17_putreg(USBDEV_INT_CDFULL|USBDEV_INT_CCEMPTY, LPC17_USBDEV_INTCLR);
|
||||
|
||||
/* Shift the command in position and mask out extra bits */
|
||||
|
||||
cmd32 = ((uint32_t)cmd << CMD_USBDEV_CMDSHIFT) & CMD_USBDEV_CMDMASK;
|
||||
|
||||
/* Load command + WR in command code register */
|
||||
|
||||
lpc17_putreg(((cmd & 0xff) << 16) + CMD_USBDEV_CMDWR, LPC17_USBDEV_CMDCODE);
|
||||
lpc17_putreg(cmd32 | CMD_USBDEV_CMDWR, LPC17_USBDEV_CMDCODE);
|
||||
|
||||
/* Wait until the command register is empty (CCEMPTY != 0, command is accepted) */
|
||||
|
||||
@ -679,7 +685,8 @@ static uint32_t lpc17_usbcmd(uint16_t cmd, uint8_t data)
|
||||
{
|
||||
/* Send data + WR and wait for CCEMPTY */
|
||||
|
||||
lpc17_putreg((data << 16) + CMD_USBDEV_DATAWR, LPC17_USBDEV_CMDCODE);
|
||||
data32 = (uint32_t)data << CMD_USBDEV_WDATASHIFT;
|
||||
lpc17_putreg(data32 | CMD_USBDEV_DATAWR, LPC17_USBDEV_CMDCODE);
|
||||
while ((lpc17_getreg(LPC17_USBDEV_INTST) & USBDEV_INT_CCEMPTY) == 0);
|
||||
}
|
||||
break;
|
||||
@ -691,7 +698,7 @@ static uint32_t lpc17_usbcmd(uint16_t cmd, uint8_t data)
|
||||
{
|
||||
/* Send command code + RD and wait for CDFULL */
|
||||
|
||||
lpc17_putreg((cmd << 16) + CMD_USBDEV_DATARD, LPC17_USBDEV_CMDCODE);
|
||||
lpc17_putreg(cmd32 | CMD_USBDEV_DATARD, LPC17_USBDEV_CMDCODE);
|
||||
while ((lpc17_getreg(LPC17_USBDEV_INTST) & USBDEV_INT_CDFULL) == 0);
|
||||
|
||||
/* Clear CDFULL and read LS data */
|
||||
@ -701,7 +708,7 @@ static uint32_t lpc17_usbcmd(uint16_t cmd, uint8_t data)
|
||||
|
||||
/* Send command code + RD and wait for CDFULL */
|
||||
|
||||
lpc17_putreg((cmd << 16) + CMD_USBDEV_DATARD, LPC17_USBDEV_CMDCODE);
|
||||
lpc17_putreg(cmd32 | CMD_USBDEV_DATARD, LPC17_USBDEV_CMDCODE);
|
||||
while ((lpc17_getreg(LPC17_USBDEV_INTST) & USBDEV_INT_CDFULL) == 0);
|
||||
|
||||
/* Read MS data */
|
||||
@ -719,7 +726,7 @@ static uint32_t lpc17_usbcmd(uint16_t cmd, uint8_t data)
|
||||
{
|
||||
/* Send command code + RD and wait for CDFULL */
|
||||
|
||||
lpc17_putreg((cmd << 16) + CMD_USBDEV_DATARD, LPC17_USBDEV_CMDCODE);
|
||||
lpc17_putreg(cmd32 | CMD_USBDEV_DATARD, LPC17_USBDEV_CMDCODE);
|
||||
while ((lpc17_getreg(LPC17_USBDEV_INTST) & USBDEV_INT_CDFULL) == 0);
|
||||
|
||||
/* Read data */
|
||||
@ -741,7 +748,7 @@ static uint32_t lpc17_usbcmd(uint16_t cmd, uint8_t data)
|
||||
{
|
||||
/* Send command code + RD and wait for CDFULL */
|
||||
|
||||
lpc17_putreg((cmd << 16) + CMD_USBDEV_DATARD, LPC17_USBDEV_CMDCODE);
|
||||
lpc17_putreg(cmd32 | CMD_USBDEV_DATARD, LPC17_USBDEV_CMDCODE);
|
||||
while ((lpc17_getreg(LPC17_USBDEV_INTST) & USBDEV_INT_CDFULL) == 0);
|
||||
|
||||
/* Read data */
|
||||
@ -754,7 +761,8 @@ static uint32_t lpc17_usbcmd(uint16_t cmd, uint8_t data)
|
||||
{
|
||||
/* Send data + RD and wait for CCEMPTY */
|
||||
|
||||
lpc17_putreg((data << 16) + CMD_USBDEV_DATAWR, LPC17_USBDEV_CMDCODE);
|
||||
data32 = (uint32_t)data << CMD_USBDEV_WDATASHIFT;
|
||||
lpc17_putreg(data32 | CMD_USBDEV_DATAWR, LPC17_USBDEV_CMDCODE);
|
||||
while ((lpc17_getreg(LPC17_USBDEV_INTST) & USBDEV_INT_CCEMPTY) == 0);
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user