Update copyrights for 2021.
[pub/lufa.git] / Demos / Device / ClassDriver / MassStorageKeyboard / MassStorageKeyboard.c
index 0076178..d0ef343 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2013.
+     Copyright (C) Dean Camera, 2021.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2013  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2021  Dean Camera (dean [at] fourwalledcubicle [dot] com)
   Copyright 2010  Matthias Hullin (lufa [at] matthias [dot] hullin [dot] net)
 
   Permission to use, copy, modify, distribute, and sell this
@@ -45,7 +45,7 @@ USB_ClassInfo_MS_Device_t Disk_MS_Interface =
        {
                .Config =
                        {
-                               .InterfaceNumber           = 0,
+                               .InterfaceNumber           = INTERFACE_ID_MassStorage,
                                .DataINEndpoint            =
                                        {
                                                .Address           = MASS_STORAGE_IN_EPADDR,
@@ -73,7 +73,7 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
        {
                .Config =
                        {
-                               .InterfaceNumber              = 1,
+                               .InterfaceNumber              = INTERFACE_ID_Keyboard,
                                .ReportINEndpoint             =
                                        {
                                                .Address              = KEYBOARD_EPADDR,
@@ -106,18 +106,29 @@ 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();
        Joystick_Init();
        Buttons_Init();
-       SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);
        Dataflash_Init();
        USB_Init();