506
/
838
Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
direction status remains unchanged;
If it is the last Data stage, before enabling the reception of the last OUT transaction, the software sets the Tx
direction status that was not used in the previous Data stage to NAK, so that even if the host starts the Status
stage immediately after the last Data stage, the USB device can still remain in the state of waiting for the end of
the control transfer, and the Rx direction state is set to VALID, ready to receive the last packet of data;
After the last OUT transaction is completed correctly, the hardware generates the USB_EPn.CTRS_RX interrupt,
and sets the Rx direction state of the USB device endpoint to NAK, and the TX direction state remains unchanged.
When the software prepares the 0-length data packet that needs to be sent in the Status stage in the interrupt, the
software changes the Tx direction status of the USB device endpoint to VALID.
Control read transfers are similar to control write transfers with the following differences:
To control read transfer, after the last IN transaction in the Data stage is completed correctly, before enabling
the Status stage in the OUT direction, in addition to setting the Rx direction status of the USB device endpoint
to VALID, you also need to set STATUS_OUT (USB_EPn.EP_KIND) to 1, indicates that the next stage will be
the Status stage in the OUT direction, and the subsequent OUT transaction must be a 0-length data packet,
otherwise an error will be generated.
After the Status stage is over, the software clears the STATUS_OUT (USB_EPn.EP_KIND) bit, the Rx direction
status of the USB device endpoint is set to VALID, ready to receive a new command request, and the Tx direction
status is set to NAK, indicating that before the next SETUP packet transmission is completed, the request for
data transfer is not accepted.
Note:
1
、
Bidirectional endpoint 0 is used as the default control endpoint to handle control transfers.
2
、
As defined in the USB2.0 specification, after the USB device receives the PID SETUP token packet, it cannot
reply with the PID NAK or STALL handshake packet, but only with the PID ACK handshake packet. If the
transmission of the SETUP packet fails, the next SETUP packet will be raised. If the Rx state of endpoint 0 is set
to STALL or NAK, the USB module can still receive the SETUP token packet.
3
、
When USB_EP0.CTRS_RX = 1, the USB module receives the SETUP token packet again, the USB module will
discard the SETUP token packet, and will not reply any handshake packet to the host, forcing the host to send
the SETUP token packet again.