Serial Port Complete - Latest Microcontroller projects

(lily) #1
Using Generic USB Controllers

PacketSize bytes. A zero-length packet (ZLP) is a short packet that contains a
PID and error-checking bits but no data bytes at all.
When a host requests data from a CDC device’s bulk IN endpoint, the end-
point can return the requested number of bytes or fewer. In each transaction
that makes up a transfer, each data packet except the last contains wMaxPacket-
Size bytes. If the number of bytes in a transfer isn’t a multiple of wMaxPacket-
Size, the last data packet is a short packet.
If the number of bytes returned is an exact multiple of wMaxPacketSize, the
endpoint returns all of the data in wMaxPacketSize packets and then responds
to a received IN token packet with a ZLP. The ZLP tells the host that the end-
point has no more data to send in the transfer. The host then knows the transfer
is complete. Even if the host has requested and received an even multiple of
wMaxPacketSize, the host may send another IN token packet, and the device
should respond with a ZLP. Don’t forget to implement this final ZLP in device
firmware.

! 
$   


String descriptors are optional but can be useful for storing serial numbers and
providing text to display to users.
The example descriptors include string descriptor zero and three string descrip-
tors indexed by the device descriptor. String descriptor zero contains the lan-
guage ID for U.S. English. Every device that has one or more string descriptors
must have string descriptor zero. The strings in U.S. English use two bytes per

Table 16-6: The bmCapabilities field of the Abstract Control Management
descriptor tells the host what requests and notifications the device supports.
  
#=
 
   
@




<
7..4 Reserved. (Reset to zero.)
3 NETWORK_CONNECTION notification
2 SEND_BREAK request
1 GET_LINE _CODING request
SET_CONTROL_LINE_STATE request
SET_LINE_CODING request
SERIAL_STATE notification
0 CLEAR_COMM_FEATURE request
GET_COMM_FEATURE request
SET_COMM_FEATURE request
Free download pdf