
10
MAX3421E Programming Guide
Programming Host Transfers
When HOST = 1, you need to
think
like a host. Instead of responding to host requests, you
generate them. This means every packet you send out requires:
•
A function address in the FNADDR register
•
An endpoint number in EP[3:0] of the HXFR register
•
A Packet ID (PID) in the HXFR register
•
Some data: OUT data in the SNDFIFO (SNDBC bytes, to be exact), or IN data in the
RCVFIFO (RCVBC bytes)
The function address and endpoint FIFO data persist in the MAX3421E until the CPU changes
them. This means, for example, to resend an OUT packet (due to an error by the peripheral) the
CPU does not need to load the SNDFIFO again. It just launches the same transfer by rewriting
the HXFR register.
The MAX3421E does the USB housekeeping work. Set up the above bits, launch the transfer by
writing the HXFR register, wait for a completion interrupt, and check the HRSLT bits (Host
Result) to see transfer results. Although the MAX3421E reports 16 host result conditions, you
will usually see one of the results shown in
Table 3
.
Table 3. Host Result Codes for Normal USB Operation
HSRLT Label
Meaning
0x00
hrSUCCESS
Successful Transfer
0x01
hrBUSY
SIE is busy, transfer pending
0x04
hrNAK
Peripheral returned NAK
0x05
hrSTALL
Perpheral returned STALL
All 16 HRSL codes are shown on page36. None of the conditions in Table 3 represents electrical
or signaling errors; they occur in normal USB operations. The hrBUSY result is for applications
that do not use the HXFRDN interrupt request to determine when a transfer completes, but
instead poll the HRSL register to check for transfer completion.
.
The host can launch seven transfer types, shown in
Table 4. HXFR Register Bit Settings for Different Transfer Types
Xfr Type
HS
ISO
OUTNIN SETUP hex
SETUP
0
0
0
1
0x10
BULK-IN
0
0
0
0
0-ep
BULK-OUT
0
0
1
0
2-ep
HS-IN
1
0
0
0
0x80
HS-OUT
1
0
1
0
0xA0
ISO-IN
0
1
0
0
4-ep
ISO-OUT
0
1
1
0
6-ep
The CPU can write the HXFR register any time when the SIE is not busy with another transfer.
The SIE takes care to avoid collisions with its automatically generated SOF/KA frame markers.