USB Info

        Calculate:      USB Token Payload           Token Payload Notes       


USB Token Payload to Address, Endpoint and CRC5:                                         top

              

Parameter                  

Value

 

Special Values

Inputs:

Middle Byte  
Last Byte  
       
       
Outputs:  Binary    
In order of arrival  
           

 

Address

 
Endpoint  
Given CRC-5  
CRC5 Input
Calculated CRC-5  
 

 



Notes:                                                                       top

USB Token packets are three bytes.  The first byte is 0x69 for IN or 0xE1 for OUT  (note the second nibble is the PID value and first nibble is it's bitwise inverse). 

The second two bytes contain three bitfields.  First is 7 bit address, second is 4 bit endpoint.  The remaining 5 bits are the CRC-5.

The order is a bit confusing as USB always sends data LSBit first.  But, CRC is calculated in order of arrival and also the bitfields are in order of arrival.

Note that CRC5 is sent MSBit first.

Note that the address is assigned by the host.  The endpoint is usually either zero (0000b) or IN (1001b) or OUT (0001b) according to this page:  http://www.usbmadesimple.co.uk/ums_7.htm

A nice explanation of the 5-bit CRC can be found here:  http://www.michael-joost.de/crc5check.pdf 

The crc is done only on the 11 bits of address and endpoint, not the PID byte.

You first xor the leading bits with binary 11111.  Then, you essentially divide by 100101 and the remainder is the CRC.

Finally, you invert the bits to get the transmitted CRC.

Note that both IN and OUT packets to the same address and endpoint will have identical last two bytes.

CRC5 calculation is ported from C code from here:

 

 

Copyright ©2016  Raymond J. Allen