GD32F10x User Manual
759
or expected according to the direction of the transfer.
After the transaction process is completed, an endpoint-specific interrupt is generated. In the
interrupt routine, the application can process it accordingly.
Transaction formatting is performed by the hardware, including CRC generation and checking.
Once the endpoint is enabled, endpoint control and status register, buffer address and
COUNT filed should not be modified by the application software. When the data transfer
operation is completed, notified by a STIF interrupt event, they can be accessed again to re-
enable a new operation.
IN transaction
When a configured and valid endpoint receives an IN token packet, it will send the data packet
to the host. If the endpoint is not valid, a NAK or STALL handshake is sent according to the
endpoint status.
In the data packet transfer process, a configured data PID will be sent firstly, then the actual
data in endpoint buffer memory is loaded into the output shift register to be transmitted. After
the data are sent, the computed CRC will be sent by hardware.
When receiving the ACK sent from the host, then the USB peripheral will toggle the data PID
and set the endpoint status to be NAK. At the same time, the successful transfer interrupt will
be triggered. In the interrupt service routine, application fill the data packet memory with data,
start next transfer by re-enable the endpoint by setting the endpoint status VALID.
OUT and SETUP transaction
USBD handles these two tokens more or less in the same way, the differences in the handling
of SETUP packets will be detailed in the following section about control transfer.
After the received endpoint is configured and enabled, host will send OUT/SETUP token to
the device. When receiving the token, USBD will access the endpoint buffer descriptor to
initialize the endpoint buffer address and length. Then the received data bytes subsequently
are packed in words (LSB mode) and transferred to the endpoint buffer. When detecting the
end of data packet, the computed CRC and received CRC are compared. If no errors occur,
an ACK handshake packet is sent to the host.
When the transaction is completed correctly, USBD will toggle the data PID and set the
endpoint status to be NAK. Then the endpoint successful transfer interrupt will be triggered
by hardware. In the interrupt service routine, the application can get the transaction type and
read the received data from the endpoint buffer. After the received data is processed, the
application should initiate further transactions by setting the endpoint status valid.
If any error happens during reception, the USBD set the error interrupt bit and still copy data
into the packet memory buffer, but will not send the ACK packet. The USBD itself can recover
from reception errors and continue to handle next transfer. The USBD never override outside
Summary of Contents for GD32F10 Series
Page 63: ...GD32F10x User Manual 63 programmed during the chip production ...
Page 117: ...GD32F10x User Manual 117 010 1 0 011 0 9 ...
Page 416: ...GD32F10x User Manual 416 shadow register updates every update event ...
Page 427: ...GD32F10x User Manual 427 value ...
Page 518: ...GD32F10x User Manual 518 These bits are not used in SPI mode ...