09.12.2012 Views

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

RM0090: Reference manual - STMicroelectronics

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

USB on-the-go high-speed (OTG_HS) <strong>RM0090</strong><br />

This section describes a regular nonisochronous OUT data transfer (control, bulk, or<br />

interrupt).<br />

Application requirements:<br />

1. Before setting up an OUT transfer, the application must allocate a buffer in the memory<br />

to accommodate all data to be received as part of the OUT transfer.<br />

2. For OUT transfers, the transfer size field in the endpoint’s transfer size register must be<br />

a multiple of the maximum packet size of the endpoint, adjusted to the DWORD<br />

boundary.<br />

– transfer size[EPNUM] = n × (MPSIZ[EPNUM] + 4 – (MPSIZ[EPNUM] mod 4))<br />

– packet count[EPNUM] = n<br />

– n > 0<br />

3. On any OUT endpoint interrupt, the application must read the endpoint’s transfer size<br />

register to calculate the size of the payload in the memory. The received payload size<br />

can be less than the programmed transfer size.<br />

– Payload size in memory = application programmed initial transfer size – core<br />

updated final transfer size<br />

– Number of USB packets in which this payload was received = application<br />

programmed initial packet count – core updated final packet count<br />

Internal data flow:<br />

1. The application must set the transfer size and packet count fields in the endpointspecific<br />

registers, clear the NAK bit, and enable the endpoint to receive the data.<br />

2. Once the NAK bit is cleared, the core starts receiving data and writes it to the receive<br />

FIFO, as long as there is space in the receive FIFO. For every data packet received on<br />

the USB, the data packet and its status are written to the receive FIFO. Every packet<br />

(maximum packet size or short packet) written to the receive FIFO decrements the<br />

packet count field for that endpoint by 1.<br />

– OUT data packets received with bad data CRC are flushed from the receive FIFO<br />

automatically.<br />

– After sending an ACK for the packet on the USB, the core discards<br />

nonisochronous OUT data packets that the host, which cannot detect the ACK, resends.<br />

The application does not detect multiple back-to-back data OUT packets<br />

on the same endpoint with the same data PID. In this case the packet count is not<br />

decremented.<br />

– If there is no space in the receive FIFO, isochronous or nonisochronous data<br />

packets are ignored and not written to the receive FIFO. Additionally,<br />

nonisochronous OUT tokens receive a NAK handshake reply.<br />

– In all the above three cases, the packet count is not decremented because no data<br />

are written to the receive FIFO.<br />

3. When the packet count becomes 0 or when a short packet is received on the endpoint,<br />

the NAK bit for that endpoint is set. Once the NAK bit is set, the isochronous or<br />

nonisochronous data packets are ignored and not written to the receive FIFO, and<br />

nonisochronous OUT tokens receive a NAK handshake reply.<br />

4. After the data are written to the receive FIFO, the application reads the data from the<br />

receive FIFO and writes it to external memory, one packet at a time per endpoint.<br />

5. At the end of every packet write on the AHB to external memory, the transfer size for<br />

the endpoint is decremented by the size of the written packet.<br />

1293/1416 Doc ID 018909 Rev 3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!