
14
MAX3421E Programming Guide
Programming a CONTROL Transfer
A host sends a CONTROL transfer in two or three stages:
1. A SETUP packet, which sends 8 bytes of “op-code” to the peripheral
2. An optional data stage, usually a BULK IN request
3. A status stage
The host sends CONTROL transfers to a peripheral’s default control endpoint zero.
1. Setup
The CPU writes the 8-byte SETUP data into the SUDFIFO. There is no byte count register
associated with the SUDFIFO because the SETUP packet payload is always 8 bytes. Then the
CPU loads the HXFR register with the value 00010000 (
), which instructs the SIE to
dispatch a SETUP packet to endpoint zero.
The SIE then sends a SETUP packet consisting of a SETUP PID, the address in the PERADDR
register, endpoint 0000, a CRC5, and EOP, and follows with a DATA0 packet containing the 8
bytes in the SUDFIFO. The SIE waits 18 bit times for the device to respond or time out, and
finally terminates the transfer by asserting the HXFRDNIRQ bit and updating the HSRLT bits
(page
). The USB spec says that a peripheral must always ACK a SETUP packet.
Note:
The SIE sends fixed DATA0 and DATA1 PID tokens for the various stages of a
CONTROL transfer, regardless of the setting of the internal data toggle.
2. Data
(optional)
If a data stage is required, it is programmed as a BULK-IN or BULK-OUT transfer. Some
CONTROL transfers, such as Set_Address, do not require a data stage because the command
data fits into the 8 bytes in the SETUP packet.
3. Status
Unique to CONTROL transfers, the status stage provides an added measure of protection for
these mission-critical transfers. A status stage consists of an IN or OUT packet in the opposite
direction as the preceding stage.
A STATUS packet is a BULK-OUT or BULK-IN transfer that contains no data and which
always uses the DATA1 PID. The programmer could send these transfers by programming
standard BULK transfers. For convenience, however, the MAX3421E provides special HS-OUT
and HS-IN launch codes for handshakes so the SIE can do the work.
HS-OUT
The host sends the OUT handshake to terminate a CONTROL-READ request such as
Get_Descriptor. To send an OUT handshake packet, the CPU loads the HXFR register with the
value 0xA0 (
).
The SIE sends the OUT PID, the address in PERADDR, endpoint zero, and a CRC5 value. The
SIE then sends a DATA1 PID, and waits 6.5 bit times for the peripheral to respond or time out.