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.

RM0008<br />

USB on-the-go full-speed (OTG_FS)<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) <strong>and</strong> 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 <strong>and</strong> process the last received<br />

SETUP packet.<br />

Figure 277. Processing a SETUP packet<br />

Wait for STUP in OTG_FS_DOEPINTx<br />

rem_supcnt =<br />

rd_reg(DOEPTSIZx)<br />

setup_cmd[31:0] = mem[4 – 2 * rem_supcnt]<br />

setup_cmd[63:32] = mem[5 – 2 * rem_supcnt]<br />

Find setup cmd type<br />

Read<br />

ctrl-rd/wr/2 stage<br />

Write<br />

2-stage<br />

setup_np_in_pkt<br />

Data IN phase<br />

setup_np_in_pkt<br />

Status IN phase<br />

rcv_out_pkt<br />

Data OUT phase<br />

ai15678<br />

● H<strong>and</strong>ling more than three back-to-back SETUP packets<br />

Per the USB 2.0 specification, normally, during a SETUP packet error, a host does not send<br />

more than three back-to-back SETUP packets to the same endpoint. However, the USB 2.0<br />

specification does not limit the number of back-to-back SETUP packets a host can send to<br />

the same endpoint. When this condition occurs, the OTG_FS controller generates an<br />

interrupt (B2BSTUP in OTG_FS_DOEPINTx).<br />

● Setting the global OUT NAK<br />

Internal data flow:<br />

1. When the application sets the Global OUT NAK (SGONAK bit in OTG_FS_DCTL), the<br />

core stops writing data, except SETUP packets, to the receive FIFO. Irrespective of the<br />

space availability in the receive FIFO, non-isochronous OUT tokens receive a NAK<br />

h<strong>and</strong>shake response, <strong>and</strong> the core ignores isochronous OUT data packets<br />

2. The core writes the Global OUT NAK pattern to the receive FIFO. The application must<br />

reserve enough receive FIFO space to write this data pattern.<br />

Doc ID 13902 Rev 9 815/995

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

Saved successfully!

Ooh no, something went wrong!