29.01.2015 Views

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

RM0008<br />

● Application requirements<br />

1. To receive a SETUP packet, the STUPCNT field (OTG_FS_DOEPTSIZx) in a control<br />

OUT endpoint must be programmed to a non-zero value. When the application<br />

programs the STUPCNT field to a non-zero value, the core receives SETUP packets<br />

<strong>and</strong> writes them to the receive FIFO, irrespective of the NAK status <strong>and</strong> EPENA bit<br />

setting in OTG_FS_DOEPCTLx. The STUPCNT field is decremented every time the<br />

control endpoint receives a SETUP packet. If the STUPCNT field is not programmed to<br />

a proper value before receiving a SETUP packet, the core still receives the SETUP<br />

packet <strong>and</strong> decrements the STUPCNT field, but the application may not be able to<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 DWORDs. Three DWORDs are required for the<br />

first SETUP packet, 1 DWORD is required for the Setup stage done DWORD <strong>and</strong><br />

6 DWORDs are required to store two extra SETUP packets among all control<br />

endpoints.<br />

– 3 DWORDs per SETUP packet are required to store 8 bytes of SETUP data <strong>and</strong> 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, <strong>and</strong> never uses this space for data packets.<br />

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

4. The application must read <strong>and</strong> discard the Setup stage done DWORD 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 <strong>and</strong> irrespective of the<br />

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

– The core internally sets the IN NAK <strong>and</strong> 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 DWORDs of data are written to the<br />

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

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

– The second DWORD contains the first 4 bytes of the SETUP comm<strong>and</strong><br />

– The third DWORD contains the last 4 bytes of the SETUP comm<strong>and</strong><br />

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

(Setup stage done DWORD) 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 DWORD from the receive FIFO, the<br />

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

indicating it can process the received SETUP packet.<br />

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

814/995 Doc ID 13902 Rev 9

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

Saved successfully!

Ooh no, something went wrong!