Fixed broken USE_RAM_DESCRIPTORS compile time option when the FIXED_NUM_CONFIGURATION...
[pub/USBasp.git] / Demos / Device / LowLevel / Keyboard / Keyboard.c
index c364d34..9342db3 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2012.
+     Copyright (C) Dean Camera, 2015.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2015  Dean Camera (dean [at] fourwalledcubicle [dot] com)
   Copyright 2010  Denver Gingerich (denver [at] ossguy [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
@@ -37,7 +37,7 @@
 
 #include "Keyboard.h"
 
-/** Indicates what report mode the host has requested, true for normal HID reporting mode, false for special boot
+/** Indicates what report mode the host has requested, true for normal HID reporting mode, \c false for special boot
  *  protocol reporting mode.
  */
 static bool UsingReportProtocol = true;
@@ -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 */