Fix warning about possible string truncation in the TempDataLogger project.
[pub/USBasp.git] / Demos / Device / ClassDriver / Keyboard / Keyboard.c
index 5c7a6f1..b12a286 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2013.
+     Copyright (C) Dean Camera, 2018.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2013  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2018  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -44,10 +44,10 @@ static uint8_t PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)];
  *  within a device can be differentiated from one another.
  */
 USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
  *  within a device can be differentiated from one another.
  */
 USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
-       {
+       {
                .Config =
                        {
                .Config =
                        {
-                               .InterfaceNumber              = 0,
+                               .InterfaceNumber              = INTERFACE_ID_Keyboard,
                                .ReportINEndpoint             =
                                        {
                                                .Address              = KEYBOARD_EPADDR,
                                .ReportINEndpoint             =
                                        {
                                                .Address              = KEYBOARD_EPADDR,
@@ -57,7 +57,7 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
                                .PrevReportINBuffer           = PrevKeyboardHIDReportBuffer,
                                .PrevReportINBufferSize       = sizeof(PrevKeyboardHIDReportBuffer),
                        },
                                .PrevReportINBuffer           = PrevKeyboardHIDReportBuffer,
                                .PrevReportINBufferSize       = sizeof(PrevKeyboardHIDReportBuffer),
                        },
-    };
+       };
 
 
 /** Main program entry point. This routine contains the overall program flow, including initial
 
 
 /** Main program entry point. This routine contains the overall program flow, including initial
@@ -80,12 +80,24 @@ int main(void)
 /** Configures the board hardware and chip peripherals for the demo's functionality. */
 void SetupHardware()
 {
 /** Configures the board hardware and chip peripherals for the demo's functionality. */
 void SetupHardware()
 {
+#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);
        /* 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();
 
        /* Hardware Initialization */
        Joystick_Init();