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 />

the channel. Port babble occurs if the core continues to receive data from the device at<br />

EOF2 (the end of frame 2, which is very close to SOF).<br />

When OTG_FS controller detects a packet babble, it stops writing data into the Rx<br />

buffer and waits for the end of packet (EOP). When it detects an EOP, it flushes already<br />

written data in the Rx buffer and generates a Babble interrupt to the application.<br />

When OTG_FS controller detects a port babble, it flushes the RxFIFO and disables the<br />

port. The core then generates a Port disabled interrupt (HPRTINT in<br />

OTG_FS_GINTSTS, PENCHNG in OTG_FS_HPRT). On receiving this interrupt, the<br />

application must determine that this is not due to an overcurrent condition (another<br />

cause of the Port Disabled interrupt) by checking POCA in OTG_FS_HPRT, then<br />

perform a soft reset. The core does not send any more tokens after it has detected a<br />

port babble condition.<br />

30.17.5 Device programming model<br />

Endpoint initialization on USB reset<br />

1. Set the NAK bit for all OUT endpoints<br />

– SNAK = 1 in OTG_FS_DOEPCTLx (for all OUT endpoints)<br />

2. Unmask the following interrupt bits<br />

– INEP0 = 1 in OTG_FS_DAINTMSK (control 0 IN endpoint)<br />

– OUTEP0 = 1 in OTG_FS_DAINTMSK (control 0 OUT endpoint)<br />

– STUP = 1 in DOEPMSK<br />

– XFRC = 1 in DOEPMSK<br />

– XFRC = 1 in DIEPMSK<br />

– TOC = 1 in DIEPMSK<br />

3. Set up the Data FIFO RAM for each of the FIFOs<br />

– Program the OTG_FS_GRXFSIZ register, to be able to receive control OUT data<br />

and setup data. If thresholding is not enabled, at a minimum, this must be equal to<br />

1 max packet size of control endpoint 0 + 2 Words (for the status of the control<br />

OUT data packet) + 10 Words (for setup packets).<br />

– Program the OTG_FS_TX0FSIZ register (depending on the FIFO number chosen)<br />

to be able to transmit control IN data. At a minimum, this must be equal to 1 max<br />

packet size of control endpoint 0.<br />

4. Program the following fields in the endpoint-specific registers for control OUT endpoint<br />

0 to receive a SETUP packet<br />

– STUPCNT = 3 in OTG_FS_DOEPTSIZ0 (to receive up to 3 back-to-back SETUP<br />

packets)<br />

At this point, all initialization required to receive SETUP packets is done.<br />

Endpoint initialization on enumeration completion<br />

1. On the Enumeration Done interrupt (ENUMDNE in OTG_FS_GINTSTS), read the<br />

OTG_FS_DSTS register to determine the enumeration speed.<br />

2. Program the MPSIZ field in OTG_FS_DIEPCTL0 to set the maximum packet size. This<br />

step configures control endpoint 0. The maximum packet size for a control endpoint<br />

depends on the enumeration speed.<br />

Doc ID 018909 Rev 3 1128/1416

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

Saved successfully!

Ooh no, something went wrong!