How to send more than 8 bytes data to PC host using USB low-speed device?
USB protocol show that low-speed USB device can transmit a maximum of 8Byte data to
device, but when send data to device like game controller class, there may need to
send more byte at one time, which requires multiple transmission.
For example, if sending 10Byte, users can use the following way:
BTS1 UE1R.4 //Check whether there is USB endpoint 1 Request?
JMP Main_Loop //There is no endpoint 1 request, jump to the main program
//There is endpoint 1 request
EP1_WR_RAM_addr_set #0x8 //Write endpoint 1FIFO Address
EP1_WR_RAM_data Buffer0 //Write data to the FIFO
EP1_WR_RAM_addr_set #0x9 //FIFO address + 1
EP1_WR_RAM_data Buffer1 //Write data to the FIFO
EP1_WR_RAM_addr_set #0xA
EP1_WR_RAM_data Buffer2
EP1_WR_RAM_addr_set #0xB
EP1_WR_RAM_data Buffer3
EP1_WR_RAM_addr_set #0xC ;
EP1_WR_RAM_data Buffer4
EP1_WR_RAM_addr_set #0xD
EP1_WR_RAM_data Buffer5
EP1_WR_RAM_addr_set #0xE
EP1_WR_RAM_data Buffer6
EP1_WR_RAM_addr_set #0xF
EP1_WR_RAM_data Buffer7
MOV A,#88H //Finished 8 byte data to the FIFO, transmit 8Byte
MOV UE1R,A
Wait:
BTS1 UE1R.4 //Wait for the host request
JMP Wait
EP1_WR_RAM_addr_set #0x8 //Write endpoint 1FIFO Address
EP1_WR_RAM_data Buffer8 //Write the ninth Byte data to the FIFO
EP1_WR_RAM_addr_set #0x9 //FIFO address + 1
EP1_WR_RAM_data Buffer9 //Write the tenth Byte data to the FIFO
MOV A,#82H //Finished 2 byte to the FIFO, transmit 2Byte
MOV UE1R,A
Main_Loop:
.........................................
For example, if sending 10Byte, users can use the following way:
BTS1 UE1R.4 //Check whether there is USB endpoint 1 Request?
JMP Main_Loop //There is no endpoint 1 request, jump to the main program
//There is endpoint 1 request
EP1_WR_RAM_addr_set #0x8 //Write endpoint 1FIFO Address
EP1_WR_RAM_data Buffer0 //Write data to the FIFO
EP1_WR_RAM_addr_set #0x9 //FIFO address + 1
EP1_WR_RAM_data Buffer1 //Write data to the FIFO
EP1_WR_RAM_addr_set #0xA
EP1_WR_RAM_data Buffer2
EP1_WR_RAM_addr_set #0xB
EP1_WR_RAM_data Buffer3
EP1_WR_RAM_addr_set #0xC ;
EP1_WR_RAM_data Buffer4
EP1_WR_RAM_addr_set #0xD
EP1_WR_RAM_data Buffer5
EP1_WR_RAM_addr_set #0xE
EP1_WR_RAM_data Buffer6
EP1_WR_RAM_addr_set #0xF
EP1_WR_RAM_data Buffer7
MOV A,#88H //Finished 8 byte data to the FIFO, transmit 8Byte
MOV UE1R,A
Wait:
BTS1 UE1R.4 //Wait for the host request
JMP Wait
EP1_WR_RAM_addr_set #0x8 //Write endpoint 1FIFO Address
EP1_WR_RAM_data Buffer8 //Write the ninth Byte data to the FIFO
EP1_WR_RAM_addr_set #0x9 //FIFO address + 1
EP1_WR_RAM_data Buffer9 //Write the tenth Byte data to the FIFO
MOV A,#82H //Finished 2 byte to the FIFO, transmit 2Byte
MOV UE1R,A
Main_Loop:
.........................................