Common prerequisites for all USB devices.
This module is based on USB device stack full interrupt driven, and supporting Sleep manager sleepmgr. For AVR and SAM3/4 devices the Clock Management clock services is supported. For SAMD devices the asfdoc_sam0_system_clock_group clock driver is supported.
The following procedure must be executed to setup the project correctly:
- Specify the clock configuration:
- XMEGA USB devices need 48MHz clock input.
XMEGA USB devices need CPU frequency higher than 12MHz.
You can use either an internal RC48MHz auto calibrated by Start of Frames or an external OSC.
- UC3 and SAM3/4 devices without USB high speed support need 48MHz clock input.
You must use a PLL and an external OSC.
- UC3 and SAM3/4 devices with USB high speed support need 12MHz clock input.
You must use an external OSC.
- UC3 devices with USBC hardware need CPU frequency higher than 25MHz.
- SAMD devices without USB high speed support need 48MHz clock input.
You should use DFLL with USBCRM.
- In conf_board.h, the define CONF_BOARD_USB_PORT must be added to enable USB lines. (Not mandatory for all boards)
- Enable interrupts
- Initialize the clock service
The usage of Sleep manager sleepmgr service is optional, but recommended to reduce power consumption:
- Initialize the sleep manager service
- Activate sleep mode when the application is in IDLE state
conf_clock.h examples with USB support.
for AVR and SAM3/4 devices, add to the initialization code:
For SAMD devices, add to the initialization code:
Add to the main IDLE loop: