硬件环境:芯片v3s ,用的Lichee Nano开发板
软件环境:裸机
问题:
usb otg作host(地址:0x01C1 9000不是OHCI)的时候插入HID设备能够枚举成功并且获取设备的PID与VID,
但是枚举成功以后端点2会一直循环触发INT中断,无法接受HID发送过来的数据。
日志:自己猜测有问题的地方注解
start v3s usb host
controllerId:0
usbHostPointer->pUSB_Otg:0x1c19000
open_usb_clock
pDebugOTG->USBC_REG_HSEOF|0x00
pDebugOTG->FIFOx|0x1c19000
pDebugOTG->Power|40:0x20
pDebugOTG->DevCtl|41:0x98
pDebugOTG->Index|42:0x03
pDebugOTG->VEND0|43:0x01
pDebugOTG->IntrTx1|44:0x00
pDebugOTG->IntrTx2|45:0x00
pDebugOTG->IntrRx1|46:0x00
pDebugOTG->IntrRx2|47:0x00
pDebugOTG->InTrTx1E|48:0x00
pDebugOTG->InTrTx2E|49:0x00
pDebugOTG->InTrRx1E|4a:0x00
pDebugOTG->InTrRx2E|4b:0x00
pDebugOTG->IntrUSBE|50:0x3e
pDebugOTG->Frame1|54:0x00
pDebugOTG->Frame2|55:0x00
pDebugOTG->TxMaxP1|80:0x00
pDebugOTG->TxMaxP2|81:0x00
pDebugOTG->CtrlSts0_Union.CSR0|82:0x00
pDebugOTG->CtrlSts0_Union.TxCSR1|82:0x00
pDebugOTG->CtrlSts1_Union.CSR02|83:0x00
pDebugOTG->CtrlSts1_Union.TxCSR2|83:0x00
pDebugOTG->RxMaxP1|84:0x00
pDebugOTG->RxMaxP2|85:0x00
pDebugOTG->RxCSR1|86:0x00
pDebugOTG->RxCSR2|87:0x00
pDebugOTG->Count_Union.Count0|88:0x00
pDebugOTG->Count_Union.RxCount1|88:0x00
pDebugOTG->RxCount2|89:0x00
pDebugOTG->TxType|8c:0x00
pDebugOTG->IntvNAKLmt0_Union.NAKLmt0|8d:0x00
pDebugOTG->IntvNAKLmt0_Union.TxIntv|8d:0x00
pDebugOTG->RxType|8e:0x00
pDebugOTG->RxIntv|8f:0x00
pDebugOTG->DyTxFIFO1|90:0x10
pDebugOTG->DyTxFIFO2|92:0x60
pDebugOTG->DyRxFIFO1|94:0x00
pDebugOTG->FIFO_Union.DyRxFIFO2|96:0x60
pDebugOTG->FIFO_Union.FIFOSize|96:0x60
pDebugOTG->FAddr|98:0x00
host init done
pDebugOTG->USBC_REG_HSEOF|0x00
pDebugOTG->FIFOx|0x1c19000
pDebugOTG->Power|40:0x60
pDebugOTG->DevCtl|41:0x19
pDebugOTG->Index|42:0x03
pDebugOTG->VEND0|43:0x01
pDebugOTG->IntrTx1|44:0x00
pDebugOTG->IntrTx2|45:0x00
pDebugOTG->IntrRx1|46:0x00
pDebugOTG->IntrRx2|47:0x00
pDebugOTG->InTrTx1E|48:0x00
pDebugOTG->InTrTx2E|49:0x00
pDebugOTG->InTrRx1E|4a:0x00
pDebugOTG->InTrRx2E|4b:0x00
pDebugOTG->IntrUSBE|50:0x3e
pDebugOTG->Frame1|54:0x00
pDebugOTG->Frame2|55:0x00
pDebugOTG->TxMaxP1|80:0x00
pDebugOTG->TxMaxP2|81:0x00
pDebugOTG->CtrlSts0_Union.CSR0|82:0x00
pDebugOTG->CtrlSts0_Union.TxCSR1|82:0x00
pDebugOTG->CtrlSts1_Union.CSR02|83:0x00
pDebugOTG->CtrlSts1_Union.TxCSR2|83:0x00
pDebugOTG->RxMaxP1|84:0x00
pDebugOTG->RxMaxP2|85:0x00
pDebugOTG->RxCSR1|86:0x00
pDebugOTG->RxCSR2|87:0x00
pDebugOTG->Count_Union.Count0|88:0x00
pDebugOTG->Count_Union.RxCount1|88:0x00
USB_OTG_INTRUSB_CON
pDebugOTG->RxCount2|89:0x00
pDebugOTG->TxType|8c:0x00
pDebugOTG->IntvNAKLmt0_Union.NAKLmt0|8d:0x00
pDebugOTG->IntvNAKLmt0_Union.TxIntv|8d:0x00
pDebugOTG->RxType|8e:0x00
pDebugOTG->RxIntv|8f:0x00
pDebugOTG->DyTxFIFO1|90:0x00
pDebugOTG->DyTxFIFO2|92:0x00
pDebugOTG->DyRxFIFO1|94:0x00
pDebugOTG->FIFO_Union.DyRxFIFO2|96:0x00
pDebugOTG->FIFO_Union.FIFOSize|96:0x00
pDebugOTG->FAddr|98:0x00
usb attach event
Full Speed Device connected
获取描述符
write[8]:80-06-00-01-00-00-08-00-
in epnum=0,epint=0x00
transferResult = 8
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=8
read[8]:12-01-00-02-00-00-00-40-
transferResult = 8
write[0]:
in epnum=0,epint=0x00
transferResult = 0
设置地址
write[8]:00-05-01-00-00-00-00-00-
in epnum=0,epint=0x00
transferResult = 8
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=0
read[0]:
transferResult = 0
获取描述符
write[8]:80-06-00-01-00-00-12-00-
in epnum=0,epint=0x00
transferResult = 8
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=18
read[18]:12-01-00-02-00-00-00-40-84-04-51-57-00-02-01-02-03-01-
transferResult = 18
write[0]:
in epnum=0,epint=0x00
transferResult = 0
获取9个字节的配置状态
write[8]:80-06-00-02-00-00-09-00-
in epnum=0,epint=0x00
transferResult = 8
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=9
read[9]:09-02-29-00-01-01-00-e0-32-
transferResult = 9
write[0]:
in epnum=0,epint=0x00
transferResult = 0
配置状态
write[8]:80-06-00-02-00-00-29-00-
in epnum=0,epint=0x00
transferResult = 8
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=41
read[41]:09-02-29-00-01-01-00-e0-32-09-04-00-00-02-03-01-01-00-09-21-11-01-00-01-22-3f-00-07-05-81-03-40-00-03-07-05-01-03-40-00-03-
transferResult = 41
write[0]:
in epnum=0,epint=0x00
transferResult = 0
设置配置状态
write[8]:00-09-01-00-00-00-00-00-
in epnum=0,epint=0x00
transferResult = 8
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=0
read[0]:
transferResult = 0
枚举完成
pDebugOTG->USBC_REG_HSEOF|0x00
pDebugOTG->FIFOx|0x1c19000
pDebugOTG->Power|40:0x60
pDebugOTG->DevCtl|41:0x5d
pDebugOTG->Index|42:0x00
pDebugOTG->VEND0|43:0x01
pDebugOTG->IntrTx1|44:0x00
pDebugOTG->IntrTx2|45:0x00
pDebugOTG->IntrRx1|46:0x00
pDebugOTG->IntrRx2|47:0x00
pDebugOTG->InTrTx1E|48:0x00
pDebugOTG->InTrTx2E|49:0x00
pDebugOTG->InTrRx1E|4a:0x00
pDebugOTG->InTrRx2E|4b:0x00
pDebugOTG->IntrUSBE|50:0x3e
pDebugOTG->Frame1|54:0xb2
pDebugOTG->Frame2|55:0x01
pDebugOTG->TxMaxP1|80:0x00
pDebugOTG->TxMaxP2|81:0x00
pDebugOTG->CtrlSts0_Union.CSR0|82:0x00
pDebugOTG->CtrlSts0_Union.TxCSR1|82:0x00
pDebugOTG->CtrlSts1_Union.CSR02|83:0x00
pDebugOTG->CtrlSts1_Union.TxCSR2|83:0x00
pDebugOTG->RxMaxP1|84:0x00
pDebugOTG->RxMaxP2|85:0x00
pDebugOTG->RxCSR1|86:0x00
pDebugOTG->RxCSR2|87:0x00
pDebugOTG->Count_Union.Count0|88:0x00
pDebugOTG->Count_Union.RxCount1|88:0x00
pDebugOTG->RxCount2|89:0x00
pDebugOTG->TxType|8c:0x00
//这里NAK超时是不是应该不为零
pDebugOTG->IntvNAKLmt0_Union.NAKLmt0|8d:0x00
pDebugOTG->IntvNAKLmt0_Union.TxIntv|8d:0x00
pDebugOTG->RxType|8e:0x00
pDebugOTG->RxIntv|8f:0x00
pDebugOTG->DyTxFIFO1|90:0x00
pDebugOTG->DyTxFIFO2|92:0x00
pDebugOTG->DyRxFIFO1|94:0x00
pDebugOTG->FIFO_Union.DyRxFIFO2|96:0x00
pDebugOTG->FIFO_Union.FIFOSize|96:0x00
pDebugOTG->FAddr|98:0x01
hid keyboard attached:pid=0x5751vid=0x484 address=1
keyboard attached
write[8]:21-0a-00-00-00-00-00-00-
in epnum=0,epint=0x00
transferResult = 8
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=0
read[0]:
transferResult = 0
write[8]:81-06-00-22-00-00-3f-00-
in epnum=0,epint=0x00
transferResult = 8
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=63
read[63]:05-01-09-06-a1-01-05-07-19-e0-29-e7-15-00-25-01-75-01-95-08-81-02-95-01-75-08-81-03-95-05-75-01-05-08-19-01-29-05-91-02-95-01-75-03-91-03-95-06-75-08-15-00-25-ff-05-07-19-00-29-65-81-00-c0-
transferResult = 63
write[0]:
in epnum=0,epint=0x00
transferResult = 0
write[8]:21-0b-01-00-00-00-00-00-
in epnum=0,epint=0x00
/*这里中断没有SETUPPKT位,SETUPPKT位回去设置Naklimit0*/
transferResult = 8
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=0
read[0]:
transferResult = 0
endpoint type 3, direction: 1//按道理来说我从机没有发送数据给主机的时候会停在这里,不会循环触发下面的读数据中断
/*下面端点2一直都是循环触发中断,但事实上我从机没有发送任何数据*/
/*
数据手册描述RxCSR1 = 0x04 = 位2 Error
The USB sets this bit when 3 attempts have been made to receive a packet and no data packet has
been received. The CPU should clear this bit. An interrupt is generated when the bit is set.
Note: This bit is only valid when the Rx endpoint is operating in Bulk or Interrupt mode. In ISO mode, it always
returns zero.
*/
in epnum=2,epint=0x04
4 : 0x4
2 2
transferResult = -512
endpoint type 3, direction: 1
in epnum=2,epint=0x04
4 : 0x4
2 2
transferResult = -512
endpoint type 3, direction: 1
in epnum=2,epint=0x04
4 : 0x4
2 2
transferResult = -512
endpoint type 3, direction: 1
in epnum=2,epint=0x04
4 : 0x4
2 2
transferResult = -512
endpoint type 3, direction: 1
in epnum=2,epint=0x04
4 : 0x4
2 2
transferResult = -512
endpoint type 3, direction: 1
in epnum=2,epint=0x04
4 : 0x4
2 2
transferResult = -512
endpoint type 3, direction: 1
/********************************************我在其他平台下正常日志********************************************/
pDebugOTG->FAddr|0x50000000
pDebugOTG->Power|01:0x60
pDebugOTG->DevCtl|0f:0x0d
pDebugOTG->Index|0e:0x03
pDebugOTG->IntrTx1|02:0x01
pDebugOTG->IntrTx2|03:0x00
pDebugOTG->IntrRx1|04:0x00
pDebugOTG->IntrRx2|05:0x00
pDebugOTG->InTrTx1E|07:0x0f
pDebugOTG->InTrTx2E|08:0x00
pDebugOTG->InTrRx1E|09:0x0e
pDebugOTG->InTrRx2E|0a:0x00
pDebugOTG->IntrUSBE|0b:0x3e
pDebugOTG->Frame1|0c:0x00
pDebugOTG->Frame2|0d:0x00
pDebugOTG->TxMaxP1|10:0x00
pDebugOTG->CtrlSts0_Union.CSR0|11:0x00
pDebugOTG->CtrlSts0_Union.TxCSR1|11:0x00
pDebugOTG->CtrlSts1_Union.CSR02|12:0x00
pDebugOTG->CtrlSts1_Union.TxCSR2|12:0x00
pDebugOTG->RxMaxP1|13:0x00
pDebugOTG->RxCSR1|14:0x00
pDebugOTG->RxCSR2|15:0x00
pDebugOTG->Count_Union.Count0|16:0x00
pDebugOTG->Count_Union.RxCount1|16:0x00
pDebugOTG->RxCount2|17:0x00
pDebugOTG->TxType|18:0x00
pDebugOTG->IntvNaKLmt0_Union.NAKLmt0|19:0x00
pDebugOTG->IntvNaKLmt0_Union.TxIntv|19:0x00
pDebugOTG->RxType|1a:0x00
pDebugOTG->RxIntv|1b:0x00
pDebugOTG->DyTxFIFO1|1c:0x50
pDebugOTG->DyTxFIFO2|1d:0x60
pDebugOTG->DyRxFIFO1|1e:0x60
pDebugOTG->FIFO_Union.DyRxFIFO2|1f:0x60
pDebugOTG->FIFO_Union.FIFOSize|1f:0x60
pDebugOTG->Faddr|00:0x00
host0init done
USB_OTG_INTRUSB_CON
in0epnum=0,epint=0x00
pDebugOTG->Faddr|0x50000000
pDebugOTG->Power|01:0x60
pDebugOTG->DevCtl|0f:0x4d
pDebugOTG->Index|0e:0x00
pDebugOTG->IntrTx1|02:0x00
pDebugOTG->IntrTx2|03:0x00
pDebugOTG->IntrRx1|04:0x00
pDebugOTG->IntrRx2|05:0x00
pDebugOTG->InTrTx1E|07:0x0f
pDebugOTG->InTrTx2E|08:0x00
pDebugOTG->InTrRx1E|09:0x0e
pDebugOTG->InTrRx2E|0a:0x00
pDebugOTG->IntrUSBE|0b:0x3e
pDebugOTG->Frame1|0c:0x00
pDebugOTG->Frame2|0d:0x00
pDebugOTG->TxMaxP1|10:0x00
pDebugOTG->CtrlSts0_Union.CSR0|11:0x00
pDebugOTG->CtrlSts0_Union.TxCSR1|11:0x00
pDebugOTG->CtrlSts1_Union.CSR02|12:0x00
pDebugOTG->CtrlSts1_Union.TxCSR2|12:0x00
pDebugOTG->RxMaxP1|13:0x00
pDebugOTG->RxCSR1|14:0x00
pDebugOTG->RxCSR2|15:0x00
pDebugOTG->Count_Union.Count0|16:0x00
pDebugOTG->Count_Union.RxCount1|16:0x00
pDebugOTG->RxCount2|17:0x00
pDebugOTG->TxType|18:0x00
pDebugOTG->IntvNaKLmt0_Union.NAKLmt0|19:0x00
pDebugOTG->IntvNaKLmt0_Union.TxIntv|19:0x00
pDebugOTG->RxType|1a:0x00
pDebugOTG->RxIntv|1b:0x00
pDebugOTG->DyTxFIFO1|1c:0x00
pDebugOTG->DyTxFIFO2|1d:0x00
pDebugOTG->DyRxFIFO1|1e:0x00
pDebugOTG->FIFO_Union.DyRxFIFO2|1f:0x00
pDebugOTG->FIFO_Union.FIFOSize|1f:0x00
pDebugOTG->Faddr|00:0x00
usb attach event
Full0Speed0Device0connected0
process0enumeration0state machine
获取描述符
write[8]:80-06-00-01-00-00-08-00-
in0epnum=0,epint=0x08
USB_OTG_CSR0_SETUPPKT
transferResult0=08
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=8
read[8]:12-01-00-02-00-00-00-40-
transferResult0= 80
write[0]:
in epnum=0,epint=0x40
USB_OTG_CSR0_STaTUSPKT
transferResult0= 00
process0the0new state
设置地址
write[8]:00-05-01-00-00-00-00-00-
in0epnum=0,epint=0x08
USB_OTG_CSR0_SETUPPKT
transferResult =080
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=0
read[0]:
transferResult0=00
process the0new0state
获取描述符
write[8]:80-06-00-01-00-00-12-00-
in epnum=0,epint=0x08
USB_OTG_CSR0_SETUPPKT
transferResult =080
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=18
read[18]:12-01-00-02-00-00-00-40-84-04-51-57-00-02-01-02-03-01-
transferResult0=018
write[0]:
in epnum=0,epint=0x40
USB_OTG_CSR0_STaTUSPKT
transferResult0=00
process the0new0state
获取9个字节的配置状态
write[8]:80-06-00-02-00-00-09-00-
in0epnum=0,epint=0x08
USB_OTG_CSR0_SETUPPKT
transferResult =080
in epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=9
read[9]:09-02-29-00-01-01-00-e0-32-
transferResult =090
write[0]:
in0epnum=0,epint=0x40
USB_OTG_CSR0_STATUSPKT
transferResult =000
process0the new0state
配置状态
write[8]:80-06-00-02-00-00-29-00-
in epnum=0,epint=0x08
USB_OTG_CSR0_SETUPPKT
transferResult0= 80
in0epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=41
read[41]:09-02-29-00-01-01-00-e0-32-09-04-00-00-02-03-01-01-00-09-21-11-01-00-01-22-3f-00-07-05-81-03-40-00-03-07-05-01-03-40-00-03-
transferResult0= 410
write[0]:
in0epnum=0,epint=0x40
USB_OTG_CSR0_STaTUSPKT
transferResult =000
process0the0new0state
设置配置状态
write[8]:00-09-01-00-00-00-00-00-
in0epnum=0,epint=0x08
USB_OTG_CSR0_SETUPPKT
transferResult0= 80
in0epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=0
read[0]:
transferResult0=000
process0the new0state
枚举完成
pDebugOTG->Faddr|0x50000000
pDebugOTG->Power|01:0x60
pDebugOTG->DevCtl|0f:0x4d
pDebugOTG->Index|0e:0x00
pDebugOTG->IntrTx1|02:0x00
pDebugOTG->IntrTx2|03:0x00
pDebugOTG->IntrRx1|04:0x00
pDebugOTG->IntrRx2|05:0x00
pDebugOTG->InTrTx1E|07:0x0f
pDebugOTG->InTrTx2E|08:0x00
pDebugOTG->InTrRx1E|09:0x0e
pDebugOTG->InTrRx2E|0a:0x00
pDebugOTG->IntrUSBE|0b:0x3e
pDebugOTG->Frame1|0c:0x15
pDebugOTG->Frame2|0d:0x02
pDebugOTG->TxMaxP1|10:0x00
pDebugOTG->CtrlSts0_Union.CSR0|11:0x00
pDebugOTG->CtrlSts0_Union.TxCSR1|11:0x00
pDebugOTG->CtrlSts1_Union.CSR02|12:0x00
pDebugOTG->CtrlSts1_Union.TxCSR2|12:0x00
pDebugOTG->RxMaxP1|13:0x00
pDebugOTG->RxCSR1|14:0x00
pDebugOTG->RxCSR2|15:0x00
pDebugOTG->Count_Union.Count0|16:0x00
pDebugOTG->Count_Union.RxCount1|16:0x00
pDebugOTG->RxCount2|17:0x00
pDebugOTG->TxType|18:0x00
pDebugOTG->IntvNAKLmt0_Union.NaKLmt0|19:0xc8
pDebugOTG->IntvNaKLmt0_Union.TxIntv|19:0xc8
pDebugOTG->RxType|1a:0x00
pDebugOTG->RxIntv|1b:0x00
pDebugOTG->DyTxFIFO1|1c:0x00
pDebugOTG->DyTxFIFO2|1d:0x00
pDebugOTG->DyRxFIFO1|1e:0x00
pDebugOTG->FIFO_Union.DyRxFIFO2|1f:0x00
pDebugOTG->FIFO_Union.FIFOSize|1f:0x00
pDebugOTG->Faddr|00:0x01
hid0keyboard attached:pid=0x5751vid=0x484 address=1
keyboard attached
write[8]:21-0a-00-00-00-00-00-00-
in0epnum=0,epint=0x08
USB_OTG_CSR0_SETUPPKT
transferResult =080
in0epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=0
read[0]:
transferResult0= 00
write[8]:81-06-00-22-00-00-3f-00-
in epnum=0,epint=0x08
USB_OTG_CSR0_SETUPPKT
transferResult =080
in0epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=63
read[63]:05-01-09-06-a1-01-05-07-19-e0-29-e7-15-00-25-01-75-01-95-08-81-02-95-01-75-08-81-03-95-05-75-01-05-08-19-01-29-05-91-02-95-01-75-03-91-03-95-06-75-08-15-00-25-ff-05-07-19-00-29-65-81-00-c0-
transferResult =063
write[0]:
in0epnum=0,epint=0x40
USB_OTG_CSR0_STaTUSPKT
transferResult0=00
write[8]:21-0b-01-00-00-00-00-00-
in0epnum=0,epint=0x08
USB_OTG_CSR0_SETUPPKT
transferResult0= 80
in0epnum=0,epint=0x01
USB_OTG_CSR0_RXPKTRDY
cnt=0
read[0]:
transferResult =000
endpoint0type03,0direction:01
/********上面是插入HID设备没有发送数据就停在这里,发送数据就进来下面中断读数据****************/
in epnum=2,epint=0x03
read[8]:00-00-22-00-00-00-00-00-
2020
transferResult = 80
5endpoint type03, direction: 1
in epnum=2,epint=0x03
read[8]:00-00-25-00-00-00-00-00-
2020
transferResult0=080
8endpoint0type03, direction: 1
in epnum=2,epint=0x03
read[8]:00-00-23-00-00-00-00-00-
2 2
离线
自顶。。。。
离线
自顶。。。。
离线