English
Language : 

EFM32WG Datasheet, PDF (281/834 Pages) List of Unclassifed Manufacturers – The EFM32WG Wonder Gecko is the ideal choice for demanding 8-, 16-, and 32-bit energy sensitive applications.
...the world's most energy friendly microcontrollers
15.4.4 Device Programming Model
Before you program the Device, be sure to read Overview: Programming the Core (p. 246) and Modes
of operation (p. 249)
15.4.4.1 Endpoint Initialization
This section addresses the following topics:
• Initialization on USB Reset (p. 281)
• Initialization on Enumeration Completion (p. 281)
• Initialization on SetAddress Command (p. 282)
• Initialization on SetConfiguration/SetInterface Command (p. 282)
• Endpoint Activation (p. 282)
• Endpoint Deactivation (p. 282)
• Device DMA/Slave Mode Initialization (p. 283)
15.4.4.1.1 Initialization on USB Reset
1. Set the NAK bit for all OUT endpoints
• USB_DOEPx_CTL.SNAK = 1 (for all OUT endpoints)
2. Unmask the following interrupt bits:
• USB_USB_DAINTMSK.INEP0 = 1 (control 0 IN endpoint)
• USB_USB_DAINTMSK.OUTEP0 = 1 (control 0 OUT endpoint)
• USB_DOEPMSK.SETUP = 1
• USB_DOEPMSK.XFERCOMPL = 1
• USB_DIEPMSK.XFERCOMPL = 1
• USB_DIEPMSK.TIMEOUTMSK = 1
3. To transmit or receive data, the device must initialize more registers as specified in Device DMA/
Slave Mode Initialization (p. 283) .
4. Set up the Data FIFO RAM for each of the FIFOs
• Program the USB_GRXFSIZ Register, to be able to receive control OUT data and setup data. At
a minimum, this must be equal to 1 max packet size of control endpoint 0 + 2 DWORDs (for the
status of the control OUT data packet) + 10 DWORDs (for setup packets).
• Program the Device IN Endpoint Transmit FIFO size register (depending on the FIFO number
chosen), to be able to transmit control IN data. At a minimum, this must be equal to 1 max packet
size of control endpoint 0.
5. Program the following fields in the endpoint-specific registers for control OUT endpoint 0 to receive
a SETUP packet
• USB_DOEP0TSIZ.SUPCNT = 3 (to receive up to 3 back-to-back SETUP packets)
• In DMA mode, USB_DOEP0DMAADDR register with a memory address to store any SETUP
packets received
At this point, all initialization required to receive SETUP packets is done, except for enabling control
OUT endpoint 0 in DMA mode.
15.4.4.1.2 Initialization on Enumeration Completion
1. On the Enumeration Done interrupt (USB_GINTSTS.ENUMDONE, read the USB_DSTS register to
determine the enumeration speed.
2. Program the USB_DIEP0CTL.MPS field to set the maximum packet size. This step configures control
endpoint 0. The maximum packet size for a control endpoint depends on the enumeration speed.
3. In DMA mode, program the USB_DOEP0CTL register to enable control OUT endpoint 0, to receive
a SETUP packet.
• USB_DOEP0CTL.EPENA = 1
2013-05-08 - Wonder Gecko Family - d0233_Rev0.50
281
www.energymicro.com