USB : USB Classes    Packing and Unpacking  

Another thing you will need to be able to handle is data items that are larger than 8 bits, like the 16-bit and 32-bit data sizes that are common in most programming languages these days. You certainly will want to be able to send and receive those without hassles too, right?

The data layout below shows a situation where a 16-bit data item and a 32-bit data item are mixed in with some smaller data items. For simplicity, we have given each of the data items a name that tells its size in bits: Data16 is a 16 bit data item, and so on. We have colored the items Data16 and Data32 to make their positions in the packet easier to see.

 

Bit
Byte 7 6 5 4 3 2 1 0
0
Data16
Data3
1
Data16
2
Data16
3
Data32
Data2
Data16
4
Data32
5
Data32
6
Data32
7
Pad
Data32

 

 
  

8 of 14
Copyright Notice and Author Information