Interrupt Service Routine (ISR) Flowcharts
13-87
USB Function Module
an ACKed transaction. If double buffering is used for an endpoint, the status
flag register is updated if there is zero or one interrupt pending for the endpoint
and is not updated if there are already two interrupts pending on the endpoint.
The local host does not need to set the Nak_En bit during normal operation.
However, this bit must be set when the local host finishes handling an endpoint
interrupt without having set the corresponding Set_FIFO_End bit. During TX
transaction, if the Nak_En bit is set, the local host must wait for a NAK interrupt
to write the TX data, to avoid a possible conflict caused by reception of a NAK
interrupt while the local host is writing the TX data.
13.6.2 Parsing the General USB Interrupt
The general USB interrupt ISR must parse the interrupt identifier register
IRQ_SRC to determine the types of general USB interrupts that are active.
These include interrupts relating to USB device state modifications (USB
reset, suspend/resume during enumeration phase) and control transfers on
endpoint 0 or non-isochronous DMA transfers in either receive or transmit
mode. Multiple interrupts may be active at any time, and all interrupts must be
dealt with by the ISR before returning from the ISR. Figure 13–14 shows an
appropriate flowchart for parsing the general USB interrupts.
13.6.3 Setup Interrupt Handler
A separate interrupt flag exists for setup transactions, so that the local host
cannot miss a setup transaction, even if it occurs during data or status phase
of another transfer (case of aborted transfer). The setup parsing function cap-
tures the control transfer request information for use in determining which USB
bus activity is needed and controlling how the local host must generate or
respond to the control transfer. This information includes:
-
bmRequestType
-
bmRequest
-
wValue
-
wIndex
-
wLength
The setup interrupt handler shown in Figure 13–15 is responsible for process-
ing setup transactions occurring on endpoint 0. It calls the routine that parses
the control transfer request information, shown in Figure 13–16 to set flags
that the rest of the ISR code can use to control proper response to control
transfers. Two flags are set by the setup interrupt handler, to be used during
endpoint 0 interrupt handlers:
-
Control read flag
-
Control write flag