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.

<strong>RM0090</strong> USB on-the-go full-speed (OTG_FS)<br />

determine the correct number of SETUP packets received in the Setup stage of a<br />

control transfer.<br />

– STUPCNT = 3 in OTG_FS_DOEPTSIZx<br />

2. The application must always allocate some extra space in the Receive data FIFO, to be<br />

able to receive up to three SETUP packets on a control endpoint.<br />

– The space to be reserved is 10 Words. Three Words are required for the first<br />

SETUP packet, 1 Word is required for the Setup stage done Word and 6 Words<br />

are required to store two extra SETUP packets among all control endpoints.<br />

– 3 Words per SETUP packet are required to store 8 bytes of SETUP data and 4<br />

bytes of SETUP status (Setup packet pattern). The core reserves this space in the<br />

receive data.<br />

– FIFO to write SETUP data only, and never uses this space for data packets.<br />

3. The application must read the 2 Words of the SETUP packet from the receive FIFO.<br />

4. The application must read and discard the Setup stage done Word from the receive<br />

FIFO.<br />

● Internal data flow<br />

5. When a SETUP packet is received, the core writes the received data to the receive<br />

FIFO, without checking for available space in the receive FIFO and irrespective of the<br />

endpoint’s NAK and STALL bit settings.<br />

– The core internally sets the IN NAK and OUT NAK bits for the control IN/OUT<br />

endpoints on which the SETUP packet was received.<br />

6. For every SETUP packet received on the USB, 3 Words of data are written to the<br />

receive FIFO, and the STUPCNT field is decremented by 1.<br />

– The first Word contains control information used internally by the core<br />

– The second Word contains the first 4 bytes of the SETUP command<br />

– The third Word contains the last 4 bytes of the SETUP command<br />

7. When the Setup stage changes to a Data IN/OUT stage, the core writes an entry<br />

(Setup stage done Word) to the receive FIFO, indicating the completion of the Setup<br />

stage.<br />

8. On the AHB side, SETUP packets are emptied by the application.<br />

9. When the application pops the Setup stage done Word from the receive FIFO, the core<br />

interrupts the application with an STUP interrupt (OTG_FS_DOEPINTx), indicating it<br />

can process the received SETUP packet.<br />

– The core clears the endpoint enable bit for control OUT endpoints.<br />

● Application programming sequence<br />

1. Program the OTG_FS_DOEPTSIZx register.<br />

– STUPCNT = 3<br />

2. Wait for the RXFLVL interrupt (OTG_FS_GINTSTS) and empty the data packets from<br />

the receive FIFO.<br />

3. Assertion of the STUP interrupt (OTG_FS_DOEPINTx) marks a successful completion<br />

of the SETUP Data Transfer.<br />

– On this interrupt, the application must read the OTG_FS_DOEPTSIZx register to<br />

determine the number of SETUP packets received and process the last received<br />

SETUP packet.<br />

Doc ID 018909 Rev 3 1132/1416

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

Saved successfully!

Ooh no, something went wrong!