User manual

...the world's most energy friendly microcontrollers
2012-04-24 - Giant Gecko Family - d0053_Rev0.96 336
www.energymicro.com
4. Check that USB_GRSTCTL.TXFFLSH =0. If it is 0, then write the TxFIFO number you want to flush
to USB_GRSTCTL.TXFNUM.
5. Set USB_GRSTCTL.TXFFLSH=1and wait for it to clear.
6. Set the USB_DCTL.GCNPINNAK bit.
15.4.7.2.4 Flushing RxFIFOs in the Core
The application can flush all RxFIFOs in the core using USB_GRSTCTL.RXFFLSH as follows:
1. Check the status of the USB_GINTSTS.GOUTNAKEFF bit. If it has been cleared, then set
USB_DCTL.SGOUTNAK=1. Else, clear USB_GINTSTS.GOUTNAKEFF.
NAK Effective interrupt = 1 indicates that the core is not writing to FIFO.
2. Wait for USB_GINTSTS.GOUTNAKEFF=1, which indicates the NAK setting has taken effect to all
OUT endpoints.
3. Poll the USB_GRSTCTL.AHBIDLE until it is 1.
AHBIDLE = 1 indicates that the core is not reading anything from the FIFO.
4. Set USB_GRSTCTL.RXFFLSH=1 and wait for it to clear.
5. Set the USB_DCTL.GCOUTNAK bit.
The Core Interrupt Handler
Figure 15.36. Core Interrupt Handler
otg_intr_ handler
Wait for interrupt
OTG
interrupt?
Read
USB_GINTSTS
Yes
Read
USB_GOTGCTL.
Generate OTG
software interrupt
Clear
interrupt
Host/
Device com mon
interrupt?
No
Yes
Generate gobal
software interrupt
No
RTL
in Device
mode?
Device
global
interrupt?
Host
global
interrupt?
YesNo
Clear interrupt
Generate host
global software
interrupt
Generate device
global software
interrupt
YesYes
No
No
Host Port
Interrupt?
Read USB_HPRT
Generate port-
specific software
interrupt.
Yes
No
Read
USB_HAINT
Read USB_HCx_INT
Generate channel-
specific software
interrupt.
Read
USB_DAINT
IN endpoint
interrupt?
Read USB_DIEPx_INT
Generate IN-
endpoint- specific
software interrupt.
Yes
No
Read USB_DOEPx_INT
Generate OUT-
endpoint- specific
software interrupt.