From 151a1c5888f8806d7e2aaf6f29cfb6deae8321ae Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 19 May 2013 22:59:46 +0200 Subject: [PATCH] Port the device mode demos to the XMEGA architecture where applicable. --- Demos/Device/LowLevel/AudioInput/AudioInput.c | 2 ++ Demos/Device/LowLevel/AudioInput/AudioInput.h | 1 + Demos/Device/LowLevel/AudioInput/asf.xml | 8 ++--- .../Device/LowLevel/AudioOutput/AudioOutput.c | 2 ++ .../Device/LowLevel/AudioOutput/AudioOutput.h | 1 + Demos/Device/LowLevel/AudioOutput/asf.xml | 8 ++--- .../DualVirtualSerial/Config/LUFAConfig.h | 33 +++++++++++++++++++ .../LowLevel/DualVirtualSerial/Descriptors.h | 2 +- .../DualVirtualSerial/DualVirtualSerial.c | 12 +++++++ .../DualVirtualSerial/DualVirtualSerial.h | 1 + .../DualVirtualSerial/DualVirtualSerial.txt | 3 ++ .../Device/LowLevel/DualVirtualSerial/asf.xml | 20 ++++++++--- .../LowLevel/GenericHID/Config/LUFAConfig.h | 33 +++++++++++++++++++ Demos/Device/LowLevel/GenericHID/GenericHID.c | 12 +++++++ Demos/Device/LowLevel/GenericHID/GenericHID.h | 3 +- .../Device/LowLevel/GenericHID/GenericHID.txt | 5 ++- Demos/Device/LowLevel/GenericHID/asf.xml | 20 ++++++++--- .../LowLevel/Joystick/Config/LUFAConfig.h | 33 +++++++++++++++++++ Demos/Device/LowLevel/Joystick/Joystick.c | 12 +++++++ Demos/Device/LowLevel/Joystick/Joystick.h | 1 + Demos/Device/LowLevel/Joystick/Joystick.txt | 3 ++ Demos/Device/LowLevel/Joystick/asf.xml | 20 ++++++++--- .../LowLevel/Keyboard/Config/LUFAConfig.h | 33 +++++++++++++++++++ Demos/Device/LowLevel/Keyboard/Keyboard.c | 14 +++++++- Demos/Device/LowLevel/Keyboard/Keyboard.h | 1 + Demos/Device/LowLevel/Keyboard/Keyboard.txt | 3 ++ Demos/Device/LowLevel/Keyboard/asf.xml | 20 ++++++++--- .../KeyboardMouse/Config/LUFAConfig.h | 33 +++++++++++++++++++ .../LowLevel/KeyboardMouse/KeyboardMouse.c | 12 +++++++ .../LowLevel/KeyboardMouse/KeyboardMouse.h | 1 + .../LowLevel/KeyboardMouse/KeyboardMouse.txt | 3 ++ Demos/Device/LowLevel/KeyboardMouse/asf.xml | 20 ++++++++--- .../Device/LowLevel/MIDI/Config/LUFAConfig.h | 33 +++++++++++++++++++ Demos/Device/LowLevel/MIDI/MIDI.c | 12 +++++++ Demos/Device/LowLevel/MIDI/MIDI.h | 1 + Demos/Device/LowLevel/MIDI/MIDI.txt | 3 ++ Demos/Device/LowLevel/MIDI/asf.xml | 20 ++++++++--- .../LowLevel/MassStorage/Config/LUFAConfig.h | 33 +++++++++++++++++++ .../Device/LowLevel/MassStorage/MassStorage.c | 12 +++++++ .../Device/LowLevel/MassStorage/MassStorage.h | 1 + .../LowLevel/MassStorage/MassStorage.txt | 3 ++ Demos/Device/LowLevel/MassStorage/asf.xml | 20 ++++++++--- .../Device/LowLevel/Mouse/Config/LUFAConfig.h | 33 +++++++++++++++++++ Demos/Device/LowLevel/Mouse/Mouse.c | 12 +++++++ Demos/Device/LowLevel/Mouse/Mouse.h | 3 +- Demos/Device/LowLevel/Mouse/Mouse.txt | 3 ++ Demos/Device/LowLevel/Mouse/asf.xml | 20 ++++++++--- .../RNDISEthernet/Config/LUFAConfig.h | 33 +++++++++++++++++++ .../LowLevel/RNDISEthernet/RNDISEthernet.c | 12 +++++++ .../LowLevel/RNDISEthernet/RNDISEthernet.h | 3 +- .../LowLevel/RNDISEthernet/RNDISEthernet.txt | 3 ++ Demos/Device/LowLevel/RNDISEthernet/asf.xml | 20 ++++++++--- .../VirtualSerial/Config/LUFAConfig.h | 33 +++++++++++++++++++ .../LowLevel/VirtualSerial/VirtualSerial.c | 12 +++++++ .../LowLevel/VirtualSerial/VirtualSerial.h | 1 + .../LowLevel/VirtualSerial/VirtualSerial.txt | 3 ++ Demos/Device/LowLevel/VirtualSerial/asf.xml | 20 ++++++++--- 57 files changed, 670 insertions(+), 54 deletions(-) diff --git a/Demos/Device/LowLevel/AudioInput/AudioInput.c b/Demos/Device/LowLevel/AudioInput/AudioInput.c index 1544f0964d..6c7bd1df40 100644 --- a/Demos/Device/LowLevel/AudioInput/AudioInput.c +++ b/Demos/Device/LowLevel/AudioInput/AudioInput.c @@ -62,12 +62,14 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#endif /* Hardware Initialization */ LEDs_Init(); diff --git a/Demos/Device/LowLevel/AudioInput/AudioInput.h b/Demos/Device/LowLevel/AudioInput/AudioInput.h index b7727a81b2..6701f8ee58 100644 --- a/Demos/Device/LowLevel/AudioInput/AudioInput.h +++ b/Demos/Device/LowLevel/AudioInput/AudioInput.h @@ -49,6 +49,7 @@ #include #include #include + #include /* Macros: */ /** Maximum audio sample value for the microphone input. */ diff --git a/Demos/Device/LowLevel/AudioInput/asf.xml b/Demos/Device/LowLevel/AudioInput/asf.xml index 767b3fd4a8..3fdfb657a0 100644 --- a/Demos/Device/LowLevel/AudioInput/asf.xml +++ b/Demos/Device/LowLevel/AudioInput/asf.xml @@ -1,14 +1,14 @@ - + - + - - + + diff --git a/Demos/Device/LowLevel/AudioOutput/AudioOutput.c b/Demos/Device/LowLevel/AudioOutput/AudioOutput.c index e77b041bd0..d47381d547 100644 --- a/Demos/Device/LowLevel/AudioOutput/AudioOutput.c +++ b/Demos/Device/LowLevel/AudioOutput/AudioOutput.c @@ -62,12 +62,14 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#endif /* Hardware Initialization */ LEDs_Init(); diff --git a/Demos/Device/LowLevel/AudioOutput/AudioOutput.h b/Demos/Device/LowLevel/AudioOutput/AudioOutput.h index 2094090352..45f0d4ab6e 100644 --- a/Demos/Device/LowLevel/AudioOutput/AudioOutput.h +++ b/Demos/Device/LowLevel/AudioOutput/AudioOutput.h @@ -47,6 +47,7 @@ #include #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Device/LowLevel/AudioOutput/asf.xml b/Demos/Device/LowLevel/AudioOutput/asf.xml index 458a8b9748..19c15c3cbf 100644 --- a/Demos/Device/LowLevel/AudioOutput/asf.xml +++ b/Demos/Device/LowLevel/AudioOutput/asf.xml @@ -1,14 +1,14 @@ - + - + - - + + diff --git a/Demos/Device/LowLevel/DualVirtualSerial/Config/LUFAConfig.h b/Demos/Device/LowLevel/DualVirtualSerial/Config/LUFAConfig.h index 3b33e2d04a..d2f780a0b6 100644 --- a/Demos/Device/LowLevel/DualVirtualSerial/Config/LUFAConfig.h +++ b/Demos/Device/LowLevel/DualVirtualSerial/Config/LUFAConfig.h @@ -85,6 +85,39 @@ // #define NO_AUTO_VBUS_MANAGEMENT // #define INVERTED_VBUS_ENABLE_LINE + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ + #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS + #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL + #define FIXED_CONTROL_ENDPOINT_SIZE 8 +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} + #define FIXED_NUM_CONFIGURATIONS 1 +// #define CONTROL_ONLY_DEVICE + #define MAX_ENDPOINT_INDEX 6 +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + #else #error Unsupported architecture for this LUFA configuration file. diff --git a/Demos/Device/LowLevel/DualVirtualSerial/Descriptors.h b/Demos/Device/LowLevel/DualVirtualSerial/Descriptors.h index 154ed0c094..a5a87dc3df 100644 --- a/Demos/Device/LowLevel/DualVirtualSerial/Descriptors.h +++ b/Demos/Device/LowLevel/DualVirtualSerial/Descriptors.h @@ -58,7 +58,7 @@ #define CDC2_RX_EPADDR (ENDPOINT_DIR_OUT | 5) /** Endpoint address of the second CDC interface's device-to-host notification IN endpoint. */ - #define CDC2_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 6) + #define CDC2_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 6) /** Size in bytes of the CDC device-to-host notification IN endpoints. */ #define CDC_NOTIFICATION_EPSIZE 8 diff --git a/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.c b/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.c index a803b4142e..45790b1e32 100644 --- a/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.c +++ b/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.c @@ -84,12 +84,24 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; +#endif /* Hardware Initialization */ Joystick_Init(); diff --git a/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.h b/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.h index 6e7c73d798..63f1f08099 100644 --- a/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.h +++ b/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.h @@ -48,6 +48,7 @@ #include #include #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.txt b/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.txt index 0897bf90bd..af263cc751 100644 --- a/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.txt +++ b/Demos/Device/LowLevel/DualVirtualSerial/DualVirtualSerial.txt @@ -13,6 +13,9 @@ * \li Series 7 USB AVRs (AT90USBxxx7) * \li Series 6 USB AVRs (AT90USBxxx6) * \li Series 4 USB AVRs (ATMEGAxxU4) + * \li Series AU XMEGA AVRs (ATXMEGAxxxAxU) + * \li Series B XMEGA AVRs (ATXMEGAxxxBxU) + * \li Series C XMEGA AVRs (ATXMEGAxxxCxU) * * \section Sec_Info USB Information: * diff --git a/Demos/Device/LowLevel/DualVirtualSerial/asf.xml b/Demos/Device/LowLevel/DualVirtualSerial/asf.xml index d3045683b3..4628f4b611 100644 --- a/Demos/Device/LowLevel/DualVirtualSerial/asf.xml +++ b/Demos/Device/LowLevel/DualVirtualSerial/asf.xml @@ -1,14 +1,26 @@ - + - + - - + + + + + + + + + + + + + + diff --git a/Demos/Device/LowLevel/GenericHID/Config/LUFAConfig.h b/Demos/Device/LowLevel/GenericHID/Config/LUFAConfig.h index 3244d3bb7b..a4ca3437f8 100644 --- a/Demos/Device/LowLevel/GenericHID/Config/LUFAConfig.h +++ b/Demos/Device/LowLevel/GenericHID/Config/LUFAConfig.h @@ -85,6 +85,39 @@ // #define NO_AUTO_VBUS_MANAGEMENT // #define INVERTED_VBUS_ENABLE_LINE + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ + #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS + #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL + #define FIXED_CONTROL_ENDPOINT_SIZE 8 +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} + #define FIXED_NUM_CONFIGURATIONS 1 +// #define CONTROL_ONLY_DEVICE + #define MAX_ENDPOINT_INDEX 2 +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + #else #error Unsupported architecture for this LUFA configuration file. diff --git a/Demos/Device/LowLevel/GenericHID/GenericHID.c b/Demos/Device/LowLevel/GenericHID/GenericHID.c index 10b344f7d9..2c55196039 100644 --- a/Demos/Device/LowLevel/GenericHID/GenericHID.c +++ b/Demos/Device/LowLevel/GenericHID/GenericHID.c @@ -57,12 +57,24 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; +#endif /* Hardware Initialization */ LEDs_Init(); diff --git a/Demos/Device/LowLevel/GenericHID/GenericHID.h b/Demos/Device/LowLevel/GenericHID/GenericHID.h index 806eda0df6..3a3c86cd68 100644 --- a/Demos/Device/LowLevel/GenericHID/GenericHID.h +++ b/Demos/Device/LowLevel/GenericHID/GenericHID.h @@ -46,9 +46,10 @@ #include "Descriptors.h" #include "Config/AppConfig.h" - + #include #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Device/LowLevel/GenericHID/GenericHID.txt b/Demos/Device/LowLevel/GenericHID/GenericHID.txt index 3d72345f32..1402740399 100644 --- a/Demos/Device/LowLevel/GenericHID/GenericHID.txt +++ b/Demos/Device/LowLevel/GenericHID/GenericHID.txt @@ -14,6 +14,9 @@ * \li Series 6 USB AVRs (AT90USBxxx6) * \li Series 4 USB AVRs (ATMEGAxxU4) * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) + * \li Series AU XMEGA AVRs (ATXMEGAxxxAxU) + * \li Series B XMEGA AVRs (ATXMEGAxxxBxU) + * \li Series C XMEGA AVRs (ATXMEGAxxxCxU) * * \section Sec_Info USB Information: * @@ -68,7 +71,7 @@ * * GENERIC_REPORT_SIZE * AppConfig.h - * This token defines the size of the device reports, both sent and received (including report ID byte). The value + * This token defines the size of the device reports, both sent and received (including report ID byte). The value * must be an integer ranging from 1 to 255. * * diff --git a/Demos/Device/LowLevel/GenericHID/asf.xml b/Demos/Device/LowLevel/GenericHID/asf.xml index 27e09ca17d..44fa5cf29b 100644 --- a/Demos/Device/LowLevel/GenericHID/asf.xml +++ b/Demos/Device/LowLevel/GenericHID/asf.xml @@ -1,14 +1,26 @@ - + - + - - + + + + + + + + + + + + + + diff --git a/Demos/Device/LowLevel/Joystick/Config/LUFAConfig.h b/Demos/Device/LowLevel/Joystick/Config/LUFAConfig.h index 3244d3bb7b..3871759b67 100644 --- a/Demos/Device/LowLevel/Joystick/Config/LUFAConfig.h +++ b/Demos/Device/LowLevel/Joystick/Config/LUFAConfig.h @@ -85,6 +85,39 @@ // #define NO_AUTO_VBUS_MANAGEMENT // #define INVERTED_VBUS_ENABLE_LINE + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ + #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS + #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL + #define FIXED_CONTROL_ENDPOINT_SIZE 8 +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} + #define FIXED_NUM_CONFIGURATIONS 1 +// #define CONTROL_ONLY_DEVICE + #define MAX_ENDPOINT_INDEX 1 +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + #else #error Unsupported architecture for this LUFA configuration file. diff --git a/Demos/Device/LowLevel/Joystick/Joystick.c b/Demos/Device/LowLevel/Joystick/Joystick.c index 4e5af8d2cc..2af5e285d4 100644 --- a/Demos/Device/LowLevel/Joystick/Joystick.c +++ b/Demos/Device/LowLevel/Joystick/Joystick.c @@ -56,12 +56,24 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; +#endif /* Hardware Initialization */ Joystick_Init(); diff --git a/Demos/Device/LowLevel/Joystick/Joystick.h b/Demos/Device/LowLevel/Joystick/Joystick.h index 02a85f564e..0cc17a59dc 100644 --- a/Demos/Device/LowLevel/Joystick/Joystick.h +++ b/Demos/Device/LowLevel/Joystick/Joystick.h @@ -49,6 +49,7 @@ #include #include #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Device/LowLevel/Joystick/Joystick.txt b/Demos/Device/LowLevel/Joystick/Joystick.txt index 55be2c3005..e3aec3d703 100644 --- a/Demos/Device/LowLevel/Joystick/Joystick.txt +++ b/Demos/Device/LowLevel/Joystick/Joystick.txt @@ -14,6 +14,9 @@ * \li Series 6 USB AVRs (AT90USBxxx6) * \li Series 4 USB AVRs (ATMEGAxxU4) * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) + * \li Series AU XMEGA AVRs (ATXMEGAxxxAxU) + * \li Series B XMEGA AVRs (ATXMEGAxxxBxU) + * \li Series C XMEGA AVRs (ATXMEGAxxxCxU) * * \section Sec_Info USB Information: * diff --git a/Demos/Device/LowLevel/Joystick/asf.xml b/Demos/Device/LowLevel/Joystick/asf.xml index 05cc1576b4..378093004e 100644 --- a/Demos/Device/LowLevel/Joystick/asf.xml +++ b/Demos/Device/LowLevel/Joystick/asf.xml @@ -1,14 +1,26 @@ - + - + - - + + + + + + + + + + + + + + diff --git a/Demos/Device/LowLevel/Keyboard/Config/LUFAConfig.h b/Demos/Device/LowLevel/Keyboard/Config/LUFAConfig.h index 3244d3bb7b..a4ca3437f8 100644 --- a/Demos/Device/LowLevel/Keyboard/Config/LUFAConfig.h +++ b/Demos/Device/LowLevel/Keyboard/Config/LUFAConfig.h @@ -85,6 +85,39 @@ // #define NO_AUTO_VBUS_MANAGEMENT // #define INVERTED_VBUS_ENABLE_LINE + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ + #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS + #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL + #define FIXED_CONTROL_ENDPOINT_SIZE 8 +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} + #define FIXED_NUM_CONFIGURATIONS 1 +// #define CONTROL_ONLY_DEVICE + #define MAX_ENDPOINT_INDEX 2 +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + #else #error Unsupported architecture for this LUFA configuration file. diff --git a/Demos/Device/LowLevel/Keyboard/Keyboard.c b/Demos/Device/LowLevel/Keyboard/Keyboard.c index 5ffe72f21f..18fde65dd9 100644 --- a/Demos/Device/LowLevel/Keyboard/Keyboard.c +++ b/Demos/Device/LowLevel/Keyboard/Keyboard.c @@ -74,12 +74,24 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; +#endif /* Hardware Initialization */ Joystick_Init(); @@ -311,7 +323,7 @@ void SendNextReport(void) else { /* Check to see if the report data has changed - if so a report MUST be sent */ - SendReport = (memcmp(&PrevKeyboardReportData, &KeyboardReportData, sizeof(USB_KeyboardReport_Data_t)) != 0); + SendReport = (memcmp(&PrevKeyboardReportData, &KeyboardReportData, sizeof(USB_KeyboardReport_Data_t)) != 0); } /* Select the Keyboard Report Endpoint */ diff --git a/Demos/Device/LowLevel/Keyboard/Keyboard.h b/Demos/Device/LowLevel/Keyboard/Keyboard.h index 4b25e34bc3..a2fcf5aa6b 100644 --- a/Demos/Device/LowLevel/Keyboard/Keyboard.h +++ b/Demos/Device/LowLevel/Keyboard/Keyboard.h @@ -51,6 +51,7 @@ #include #include #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Device/LowLevel/Keyboard/Keyboard.txt b/Demos/Device/LowLevel/Keyboard/Keyboard.txt index f7e2829614..a1582a8f94 100644 --- a/Demos/Device/LowLevel/Keyboard/Keyboard.txt +++ b/Demos/Device/LowLevel/Keyboard/Keyboard.txt @@ -14,6 +14,9 @@ * \li Series 6 USB AVRs (AT90USBxxx6) * \li Series 4 USB AVRs (ATMEGAxxU4) * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) + * \li Series AU XMEGA AVRs (ATXMEGAxxxAxU) + * \li Series B XMEGA AVRs (ATXMEGAxxxBxU) + * \li Series C XMEGA AVRs (ATXMEGAxxxCxU) * * \section Sec_Info USB Information: * diff --git a/Demos/Device/LowLevel/Keyboard/asf.xml b/Demos/Device/LowLevel/Keyboard/asf.xml index bae98489e2..d242754fec 100644 --- a/Demos/Device/LowLevel/Keyboard/asf.xml +++ b/Demos/Device/LowLevel/Keyboard/asf.xml @@ -1,14 +1,26 @@ - + - + - - + + + + + + + + + + + + + + diff --git a/Demos/Device/LowLevel/KeyboardMouse/Config/LUFAConfig.h b/Demos/Device/LowLevel/KeyboardMouse/Config/LUFAConfig.h index 3244d3bb7b..4873f80315 100644 --- a/Demos/Device/LowLevel/KeyboardMouse/Config/LUFAConfig.h +++ b/Demos/Device/LowLevel/KeyboardMouse/Config/LUFAConfig.h @@ -85,6 +85,39 @@ // #define NO_AUTO_VBUS_MANAGEMENT // #define INVERTED_VBUS_ENABLE_LINE + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ + #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS + #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL + #define FIXED_CONTROL_ENDPOINT_SIZE 8 +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} + #define FIXED_NUM_CONFIGURATIONS 1 +// #define CONTROL_ONLY_DEVICE + #define MAX_ENDPOINT_INDEX 3 +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + #else #error Unsupported architecture for this LUFA configuration file. diff --git a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c index 3eba6c383b..c924bacb70 100644 --- a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c +++ b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.c @@ -65,12 +65,24 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; +#endif /* Hardware Initialization */ Joystick_Init(); diff --git a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h index ac42b346eb..d74482fba2 100644 --- a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h +++ b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.h @@ -46,6 +46,7 @@ #include #include #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.txt b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.txt index b994422a8f..20c89cc80c 100644 --- a/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.txt +++ b/Demos/Device/LowLevel/KeyboardMouse/KeyboardMouse.txt @@ -14,6 +14,9 @@ * \li Series 6 USB AVRs (AT90USBxxx6) * \li Series 4 USB AVRs (ATMEGAxxU4) * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) + * \li Series AU XMEGA AVRs (ATXMEGAxxxAxU) + * \li Series B XMEGA AVRs (ATXMEGAxxxBxU) + * \li Series C XMEGA AVRs (ATXMEGAxxxCxU) * * \section Sec_Info USB Information: * diff --git a/Demos/Device/LowLevel/KeyboardMouse/asf.xml b/Demos/Device/LowLevel/KeyboardMouse/asf.xml index 247eeea7f4..d3eca33a40 100644 --- a/Demos/Device/LowLevel/KeyboardMouse/asf.xml +++ b/Demos/Device/LowLevel/KeyboardMouse/asf.xml @@ -1,14 +1,26 @@ - + - + - - + + + + + + + + + + + + + + diff --git a/Demos/Device/LowLevel/MIDI/Config/LUFAConfig.h b/Demos/Device/LowLevel/MIDI/Config/LUFAConfig.h index 3244d3bb7b..a4ca3437f8 100644 --- a/Demos/Device/LowLevel/MIDI/Config/LUFAConfig.h +++ b/Demos/Device/LowLevel/MIDI/Config/LUFAConfig.h @@ -85,6 +85,39 @@ // #define NO_AUTO_VBUS_MANAGEMENT // #define INVERTED_VBUS_ENABLE_LINE + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ + #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS + #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL + #define FIXED_CONTROL_ENDPOINT_SIZE 8 +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} + #define FIXED_NUM_CONFIGURATIONS 1 +// #define CONTROL_ONLY_DEVICE + #define MAX_ENDPOINT_INDEX 2 +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + #else #error Unsupported architecture for this LUFA configuration file. diff --git a/Demos/Device/LowLevel/MIDI/MIDI.c b/Demos/Device/LowLevel/MIDI/MIDI.c index deb05614f2..15e08392ba 100644 --- a/Demos/Device/LowLevel/MIDI/MIDI.c +++ b/Demos/Device/LowLevel/MIDI/MIDI.c @@ -56,12 +56,24 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; +#endif /* Hardware Initialization */ Joystick_Init(); diff --git a/Demos/Device/LowLevel/MIDI/MIDI.h b/Demos/Device/LowLevel/MIDI/MIDI.h index b97678a2fc..fd07f62f76 100644 --- a/Demos/Device/LowLevel/MIDI/MIDI.h +++ b/Demos/Device/LowLevel/MIDI/MIDI.h @@ -49,6 +49,7 @@ #include #include #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Device/LowLevel/MIDI/MIDI.txt b/Demos/Device/LowLevel/MIDI/MIDI.txt index 362250c41e..9ac3d9ea82 100644 --- a/Demos/Device/LowLevel/MIDI/MIDI.txt +++ b/Demos/Device/LowLevel/MIDI/MIDI.txt @@ -14,6 +14,9 @@ * \li Series 6 USB AVRs (AT90USBxxx6) * \li Series 4 USB AVRs (ATMEGAxxU4) * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) + * \li Series AU XMEGA AVRs (ATXMEGAxxxAxU) + * \li Series B XMEGA AVRs (ATXMEGAxxxBxU) + * \li Series C XMEGA AVRs (ATXMEGAxxxCxU) * * \section Sec_Info USB Information: * diff --git a/Demos/Device/LowLevel/MIDI/asf.xml b/Demos/Device/LowLevel/MIDI/asf.xml index 652d51acd4..de8a016a95 100644 --- a/Demos/Device/LowLevel/MIDI/asf.xml +++ b/Demos/Device/LowLevel/MIDI/asf.xml @@ -1,14 +1,26 @@ - + - + - - + + + + + + + + + + + + + + diff --git a/Demos/Device/LowLevel/MassStorage/Config/LUFAConfig.h b/Demos/Device/LowLevel/MassStorage/Config/LUFAConfig.h index 3b33e2d04a..da728ec292 100644 --- a/Demos/Device/LowLevel/MassStorage/Config/LUFAConfig.h +++ b/Demos/Device/LowLevel/MassStorage/Config/LUFAConfig.h @@ -85,6 +85,39 @@ // #define NO_AUTO_VBUS_MANAGEMENT // #define INVERTED_VBUS_ENABLE_LINE + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ + #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS + #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL + #define FIXED_CONTROL_ENDPOINT_SIZE 8 +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} + #define FIXED_NUM_CONFIGURATIONS 1 +// #define CONTROL_ONLY_DEVICE + #define MAX_ENDPOINT_INDEX 4 +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + #else #error Unsupported architecture for this LUFA configuration file. diff --git a/Demos/Device/LowLevel/MassStorage/MassStorage.c b/Demos/Device/LowLevel/MassStorage/MassStorage.c index 7e8bcc4e57..cfb1686fd9 100644 --- a/Demos/Device/LowLevel/MassStorage/MassStorage.c +++ b/Demos/Device/LowLevel/MassStorage/MassStorage.c @@ -67,12 +67,24 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; +#endif /* Hardware Initialization */ LEDs_Init(); diff --git a/Demos/Device/LowLevel/MassStorage/MassStorage.h b/Demos/Device/LowLevel/MassStorage/MassStorage.h index edb3b855e4..634ed09c73 100644 --- a/Demos/Device/LowLevel/MassStorage/MassStorage.h +++ b/Demos/Device/LowLevel/MassStorage/MassStorage.h @@ -51,6 +51,7 @@ #include #include #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Device/LowLevel/MassStorage/MassStorage.txt b/Demos/Device/LowLevel/MassStorage/MassStorage.txt index b5f9f9cef7..528dbe7536 100644 --- a/Demos/Device/LowLevel/MassStorage/MassStorage.txt +++ b/Demos/Device/LowLevel/MassStorage/MassStorage.txt @@ -14,6 +14,9 @@ * \li Series 6 USB AVRs (AT90USBxxx6) * \li Series 4 USB AVRs (ATMEGAxxU4) * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) + * \li Series AU XMEGA AVRs (ATXMEGAxxxAxU) + * \li Series B XMEGA AVRs (ATXMEGAxxxBxU) + * \li Series C XMEGA AVRs (ATXMEGAxxxCxU) * * \section Sec_Info USB Information: * diff --git a/Demos/Device/LowLevel/MassStorage/asf.xml b/Demos/Device/LowLevel/MassStorage/asf.xml index a859733f58..46f25cca51 100644 --- a/Demos/Device/LowLevel/MassStorage/asf.xml +++ b/Demos/Device/LowLevel/MassStorage/asf.xml @@ -1,14 +1,26 @@ - + - + - - + + + + + + + + + + + + + + diff --git a/Demos/Device/LowLevel/Mouse/Config/LUFAConfig.h b/Demos/Device/LowLevel/Mouse/Config/LUFAConfig.h index 3244d3bb7b..3871759b67 100644 --- a/Demos/Device/LowLevel/Mouse/Config/LUFAConfig.h +++ b/Demos/Device/LowLevel/Mouse/Config/LUFAConfig.h @@ -85,6 +85,39 @@ // #define NO_AUTO_VBUS_MANAGEMENT // #define INVERTED_VBUS_ENABLE_LINE + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ + #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS + #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL + #define FIXED_CONTROL_ENDPOINT_SIZE 8 +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} + #define FIXED_NUM_CONFIGURATIONS 1 +// #define CONTROL_ONLY_DEVICE + #define MAX_ENDPOINT_INDEX 1 +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + #else #error Unsupported architecture for this LUFA configuration file. diff --git a/Demos/Device/LowLevel/Mouse/Mouse.c b/Demos/Device/LowLevel/Mouse/Mouse.c index 7575a81f56..601eebec58 100644 --- a/Demos/Device/LowLevel/Mouse/Mouse.c +++ b/Demos/Device/LowLevel/Mouse/Mouse.c @@ -73,12 +73,24 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; +#endif /* Hardware Initialization */ Joystick_Init(); diff --git a/Demos/Device/LowLevel/Mouse/Mouse.h b/Demos/Device/LowLevel/Mouse/Mouse.h index e11b1fac84..23cf1335ca 100644 --- a/Demos/Device/LowLevel/Mouse/Mouse.h +++ b/Demos/Device/LowLevel/Mouse/Mouse.h @@ -45,11 +45,12 @@ #include #include "Descriptors.h" - + #include #include #include #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Device/LowLevel/Mouse/Mouse.txt b/Demos/Device/LowLevel/Mouse/Mouse.txt index 0664cba635..7f1c38430f 100644 --- a/Demos/Device/LowLevel/Mouse/Mouse.txt +++ b/Demos/Device/LowLevel/Mouse/Mouse.txt @@ -14,6 +14,9 @@ * \li Series 6 USB AVRs (AT90USBxxx6) * \li Series 4 USB AVRs (ATMEGAxxU4) * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) + * \li Series AU XMEGA AVRs (ATXMEGAxxxAxU) + * \li Series B XMEGA AVRs (ATXMEGAxxxBxU) + * \li Series C XMEGA AVRs (ATXMEGAxxxCxU) * * \section Sec_Info USB Information: * diff --git a/Demos/Device/LowLevel/Mouse/asf.xml b/Demos/Device/LowLevel/Mouse/asf.xml index ed0c537c8b..0f471ff08f 100644 --- a/Demos/Device/LowLevel/Mouse/asf.xml +++ b/Demos/Device/LowLevel/Mouse/asf.xml @@ -1,14 +1,26 @@ - + - + - - + + + + + + + + + + + + + + diff --git a/Demos/Device/LowLevel/RNDISEthernet/Config/LUFAConfig.h b/Demos/Device/LowLevel/RNDISEthernet/Config/LUFAConfig.h index 3244d3bb7b..4873f80315 100644 --- a/Demos/Device/LowLevel/RNDISEthernet/Config/LUFAConfig.h +++ b/Demos/Device/LowLevel/RNDISEthernet/Config/LUFAConfig.h @@ -85,6 +85,39 @@ // #define NO_AUTO_VBUS_MANAGEMENT // #define INVERTED_VBUS_ENABLE_LINE + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ + #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS + #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL + #define FIXED_CONTROL_ENDPOINT_SIZE 8 +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} + #define FIXED_NUM_CONFIGURATIONS 1 +// #define CONTROL_ONLY_DEVICE + #define MAX_ENDPOINT_INDEX 3 +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + #else #error Unsupported architecture for this LUFA configuration file. diff --git a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c index 52085f89c2..2837a1088b 100644 --- a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c +++ b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.c @@ -62,12 +62,24 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; +#endif /* Hardware Initialization */ LEDs_Init(); diff --git a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.h b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.h index ec53e7bcad..37affda8d6 100644 --- a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.h +++ b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.h @@ -51,10 +51,11 @@ #include "Lib/ARP.h" #include "Lib/Webserver.h" #include "Config/AppConfig.h" - + #include #include #include + #include /* Macros: */ /** Notification value to indicate that a frame is ready to be read by the host. */ diff --git a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.txt b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.txt index ac72d4ae7f..aafa3cc439 100644 --- a/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.txt +++ b/Demos/Device/LowLevel/RNDISEthernet/RNDISEthernet.txt @@ -12,6 +12,9 @@ * * \li Series 7 USB AVRs (AT90USBxxx7) * \li Series 6 USB AVRs (AT90USBxxx6) + * \li Series AU XMEGA AVRs (ATXMEGAxxxAxU) + * \li Series B XMEGA AVRs (ATXMEGAxxxBxU) + * \li Series C XMEGA AVRs (ATXMEGAxxxCxU) * * \section Sec_Info USB Information: * diff --git a/Demos/Device/LowLevel/RNDISEthernet/asf.xml b/Demos/Device/LowLevel/RNDISEthernet/asf.xml index 59c373a0e2..12fc761f8e 100644 --- a/Demos/Device/LowLevel/RNDISEthernet/asf.xml +++ b/Demos/Device/LowLevel/RNDISEthernet/asf.xml @@ -1,14 +1,26 @@ - + - + - - + + + + + + + + + + + + + + diff --git a/Demos/Device/LowLevel/VirtualSerial/Config/LUFAConfig.h b/Demos/Device/LowLevel/VirtualSerial/Config/LUFAConfig.h index 3244d3bb7b..7b4e026a14 100644 --- a/Demos/Device/LowLevel/VirtualSerial/Config/LUFAConfig.h +++ b/Demos/Device/LowLevel/VirtualSerial/Config/LUFAConfig.h @@ -85,6 +85,39 @@ // #define NO_AUTO_VBUS_MANAGEMENT // #define INVERTED_VBUS_ENABLE_LINE + #elif (ARCH == ARCH_XMEGA) + + /* Non-USB Related Configuration Tokens: */ +// #define DISABLE_TERMINAL_CODES + + /* USB Class Driver Related Tokens: */ +// #define HID_HOST_BOOT_PROTOCOL_ONLY +// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here} +// #define HID_USAGE_STACK_DEPTH {Insert Value Here} +// #define HID_MAX_COLLECTIONS {Insert Value Here} +// #define HID_MAX_REPORTITEMS {Insert Value Here} +// #define HID_MAX_REPORT_IDS {Insert Value Here} +// #define NO_CLASS_DRIVER_AUTOFLUSH + + /* General USB Driver Related Tokens: */ + #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH) +// #define USB_STREAM_TIMEOUT_MS {Insert Value Here} +// #define NO_LIMITED_CONTROLLER_CONNECT +// #define NO_SOF_EVENTS + + /* USB Device Mode Driver Related Tokens: */ +// #define USE_RAM_DESCRIPTORS + #define USE_FLASH_DESCRIPTORS +// #define USE_EEPROM_DESCRIPTORS +// #define NO_INTERNAL_SERIAL + #define FIXED_CONTROL_ENDPOINT_SIZE 8 +// #define DEVICE_STATE_AS_GPIOR {Insert Value Here} + #define FIXED_NUM_CONFIGURATIONS 1 +// #define CONTROL_ONLY_DEVICE + #define MAX_ENDPOINT_INDEX 4 +// #define NO_DEVICE_REMOTE_WAKEUP +// #define NO_DEVICE_SELF_POWER + #else #error Unsupported architecture for this LUFA configuration file. diff --git a/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.c b/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.c index 998aede8ae..3c005f7d34 100644 --- a/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.c +++ b/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.c @@ -70,12 +70,24 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { +#if (ARCH == ARCH_AVR8) /* Disable watchdog if enabled by bootloader/fuses */ MCUSR &= ~(1 << WDRF); wdt_disable(); /* Disable clock division */ clock_prescale_set(clock_div_1); +#elif (ARCH == ARCH_XMEGA) + /* Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it */ + XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU); + XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL); + + /* Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference */ + XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ); + XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB); + + PMIC.CTRL = PMIC_LOLVLEN_bm | PMIC_MEDLVLEN_bm | PMIC_HILVLEN_bm; +#endif /* Hardware Initialization */ Joystick_Init(); diff --git a/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.h b/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.h index 5b985ced54..db5fe9d047 100644 --- a/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.h +++ b/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.h @@ -48,6 +48,7 @@ #include #include #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.txt b/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.txt index e0a3291b4f..61b665674f 100644 --- a/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.txt +++ b/Demos/Device/LowLevel/VirtualSerial/VirtualSerial.txt @@ -14,6 +14,9 @@ * \li Series 6 USB AVRs (AT90USBxxx6) * \li Series 4 USB AVRs (ATMEGAxxU4) * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) + * \li Series AU XMEGA AVRs (ATXMEGAxxxAxU) + * \li Series B XMEGA AVRs (ATXMEGAxxxBxU) + * \li Series C XMEGA AVRs (ATXMEGAxxxCxU) * * \section Sec_Info USB Information: * diff --git a/Demos/Device/LowLevel/VirtualSerial/asf.xml b/Demos/Device/LowLevel/VirtualSerial/asf.xml index bb2c0fcc83..091bb1dd0c 100644 --- a/Demos/Device/LowLevel/VirtualSerial/asf.xml +++ b/Demos/Device/LowLevel/VirtualSerial/asf.xml @@ -1,14 +1,26 @@ - + - + - - + + + + + + + + + + + + + +