aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/CodeTemplates
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2013-01-27 15:48:09 +0000
committerDean Camera <dean@fourwalledcubicle.com>2013-01-27 15:48:09 +0000
commit0e64a9d0c290ff6eb504323dc3b30fdddefdcc85 (patch)
tree4d9494747759ff31c4cc6af2efbc3728bf88495b /LUFA/CodeTemplates
parent3929cae00ea7fc0127ba0cde8db30e92ff713f87 (diff)
downloadlufa-0e64a9d0c290ff6eb504323dc3b30fdddefdcc85.tar.gz
lufa-0e64a9d0c290ff6eb504323dc3b30fdddefdcc85.tar.bz2
lufa-0e64a9d0c290ff6eb504323dc3b30fdddefdcc85.zip
Update Atmel Studio core board templates to use different templates for each driver, so that the project caption contains the architecture. Update individual board modules to include the relevant board hardware drivers.
Diffstat (limited to 'LUFA/CodeTemplates')
-rw-r--r--LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.c33
-rw-r--r--LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.h3
-rw-r--r--LUFA/CodeTemplates/DeviceTemplate/asf.xml16
-rw-r--r--LUFA/CodeTemplates/HostTemplate/asf.xml2
4 files changed, 41 insertions, 13 deletions
diff --git a/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.c b/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.c
index 893c733a6..e107c8680 100644
--- a/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.c
+++ b/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.c
@@ -55,15 +55,30 @@ int main(void)
/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
- /* Disable watchdog if enabled by bootloader/fuses */
- MCUSR &= ~(1 << WDRF);
- wdt_disable();
-
- /* Disable clock division */
- clock_prescale_set(clock_div_1);
-
- /* Hardware Initialization */
- USB_Init(USB_MODE_Device, USB_DEVICE_OPT_FULLSPEED | USB_OPT_AUTO_PLL);
+ #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);
+
+ /* Hardware Initialization */
+ USB_Init(USB_MODE_Device, USB_DEVICE_OPT_FULLSPEED | USB_OPT_AUTO_PLL);
+ #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;
+
+ /* Hardware Initialization */
+ USB_Init(USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH);
+ #endif
}
/** Event handler for the library USB Connection event. */
diff --git a/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.h b/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.h
index 9dac556a1..bc6875bcc 100644
--- a/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.h
+++ b/LUFA/CodeTemplates/DeviceTemplate/DeviceApplication.h
@@ -34,13 +34,14 @@
*/
#ifndef _USB_DEVICE_APPLICATION_H_
-#define _USB_DEVICE_APPLICATION_
+#define _USB_DEVICE_APPLICATION_H_
/* Includes: */
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
+ #include <LUFA/Platform/Platform.h>
#include <LUFA/Drivers/USB/USB.h>
#include "Descriptors.h"
diff --git a/LUFA/CodeTemplates/DeviceTemplate/asf.xml b/LUFA/CodeTemplates/DeviceTemplate/asf.xml
index 0cceef9f0..cdb4c605a 100644
--- a/LUFA/CodeTemplates/DeviceTemplate/asf.xml
+++ b/LUFA/CodeTemplates/DeviceTemplate/asf.xml
@@ -1,7 +1,7 @@
<asf xmlversion="1.0">
- <project caption="USB Device Template" id="lufa.templates.device.project">
+ <project caption="USB Device Template" id="lufa.templates.device.project.avr8">
<require idref="lufa.templates.device"/>
- <require idref="lufa.boards.dummy"/>
+ <require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8_template"/>
<device-support value="at90usb1287"/>
@@ -11,6 +11,18 @@
<build type="define" name="F_USB" value="8000000UL"/>
</project>
+ <project caption="USB Device Template" id="lufa.templates.device.project.xmega">
+ <require idref="lufa.templates.device"/>
+ <require idref="lufa.boards.dummy.xmega"/>
+ <generator value="as5_8_template"/>
+
+ <device-support value="atxmega256a3bu"/>
+ <config name="lufa.drivers.board.name" value="a3bu_xplained"/>
+
+ <build type="define" name="F_CPU" value="32000000UL"/>
+ <build type="define" name="F_USB" value="48000000UL"/>
+ </project>
+
<module type="application" id="lufa.templates.device" caption="USB Device Template">
<info type="description" value="summary">
Template for a LUFA USB device mode application.
diff --git a/LUFA/CodeTemplates/HostTemplate/asf.xml b/LUFA/CodeTemplates/HostTemplate/asf.xml
index 0c20c4b12..9acef597e 100644
--- a/LUFA/CodeTemplates/HostTemplate/asf.xml
+++ b/LUFA/CodeTemplates/HostTemplate/asf.xml
@@ -1,7 +1,7 @@
<asf xmlversion="1.0">
<project caption="USB Host Template" id="lufa.templates.host.project">
<require idref="lufa.templates.host"/>
- <require idref="lufa.boards.dummy"/>
+ <require idref="lufa.boards.dummy.avr8"/>
<generator value="as5_8_template"/>
<device-support value="at90usb1287"/>