Fix STK525 and STK526 device support in the Atmel Studio extension.
[pub/USBasp.git] / Demos / Device / ClassDriver / DualVirtualSerial / DualVirtualSerial.c
index b7d0455..070ebc7 100644 (file)
@@ -45,7 +45,7 @@ USB_ClassInfo_CDC_Device_t VirtualSerial1_CDC_Interface =
        {
                .Config =
                        {
-                               .ControlInterfaceNumber   = 0,
+                               .ControlInterfaceNumber   = INTERFACE_ID_CDC1_CCI,
                                .DataINEndpoint           =
                                        {
                                                .Address          = CDC1_TX_EPADDR,
@@ -76,7 +76,7 @@ USB_ClassInfo_CDC_Device_t VirtualSerial2_CDC_Interface =
        {
                .Config =
                        {
-                               .ControlInterfaceNumber   = 2,
+                               .ControlInterfaceNumber   = INTERFACE_ID_CDC2_CCI,
                                .DataINEndpoint           =
                                        {
                                                .Address          = CDC2_TX_EPADDR,
@@ -131,12 +131,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();