21.3.11 Endpoint 0
Endpoint0 is managed through the USB register E0CSR. The INDEX register must be loaded with 0x00 to access the E0CSR register.
An Endpoint0 interrupt is generated when one of the following occurs:
• A data packet (OUT or SETUP) has been received and loaded into the Endpoint0 FIFO.
• The OPRDY bit is set to 1 by hardware.
• An IN data packet has successfully been unloaded from the Endpoint0 FIFO and transmitted to the host; INPRDY is reset to 0 by
hardware.
• An IN transaction is completed (this interrupt generated during the status stage of the transaction).
• Hardware sets the STSTL bit after a control transaction ended due to a protocol violation.
• Hardware sets the SUEND bit because a control transfer ended before firmware set the DATAEND bit.
The E0CNT register holds the number of received data bytes in the Endpoint0 FIFO. Hardware will automatically detect protocol errors
and send a STALL condition in response. Firmware may force a STALL condition to abort the current transfer. When a STALL condition
is generated, the STSTL bit will be set to 1 and an interrupt generated. The following conditions will cause hardware to generate a
STALL condition:
• The host sends an OUT token during a OUT data phase after the DATAEND bit has been set to 1.
• The host sends an IN token during an IN data phase after the DATAEND bit has been set to 1.
• The host sends a packet that exceeds the maximum packet size for Endpoint0.
• The host sends a non-zero length DATA1 packet during the status phase of an IN transaction.
• Firmware sets the SDSTL bit to 1.
Endpoint0 SETUP Transactions
All control transfers must begin with a SETUP packet. SETUP packets are similar to OUT packets, containing an 8-byte data field sent
by the host. Any SETUP packet containing a command field of anything other than 8 bytes will be automatically rejected by USB0. An
Endpoint0 interrupt is generated when the data from a SETUP packet is loaded into the Endpoint0 FIFO. Software should unload the
command from the Endpoint0 FIFO, decode the command, perform any necessary tasks, and set the SOPRDY bit to indicate that it has
serviced the OUT packet.
Endpoint0 IN Transactions
When a SETUP request is received that requires the USB interface to transmit data to the host, one or more IN requests will be sent by
the host. For the first IN transaction, firmware should load an IN packet into the Endpoint0 FIFO, and set the INPRDY bit. An interrupt
will be generated when an IN packet is transmitted successfully. Note that no interrupt will be generated if an IN request is received
before firmware has loaded a packet into the Endpoint0 FIFO. If the requested data exceeds the maximum packet size for Endpoint0
(as reported to the host), the data should be split into multiple packets; each packet should be of the maximum packet size excluding
the last (residual) packet. If the requested data is an integer multiple of the maximum packet size for Endpoint0, the last data packet
should be a zero-length packet signaling the end of the transfer. Firmware should set the DATAEND bit to 1 after loading into the End-
point0 FIFO the last data packet for a transfer.
Upon reception of the first IN token for a particular control transfer, Endpoint0 is said to be in Transmit Mode. In this mode, only IN
tokens should be sent by the host to Endpoint0. The SUEND bit is set to 1 if a SETUP or OUT token is received while Endpoint0 is in
Transmit Mode. Endpoint0 will remain in Transmit Mode until any of the following occur:
• The USB interface receives an Endpoint0 SETUP or OUT token.
• Firmware sends a packet less than the maximum Endpoint0 packet size.
• Firmware sends a zero-length packet.
Firmware should set the DATAEND bit to 1 when sending a zero-length packet or sending a packet less than the maximum Endpoint0
size. The SIE will transmit a NAK in response to an IN token if there is no packet ready in the IN FIFO (INPRDY = 0).
EFM8UB3 Reference Manual
Universal Serial Bus (USB0)
silabs.com
| Building a more connected world.
Rev. 0.2 | 318