Update Studio Integration DLL, to include package logging.
[pub/USBasp.git] / Demos / Host / ClassDriver / VirtualSerialHost / VirtualSerialHost.c
index 72d7e58..f9dffc0 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2015.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2015  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
@@ -18,7 +18,7 @@
   advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
-  The author disclaim all warranties with regard to this
+  The author disclaims all warranties with regard to this
   software, including all implied warranties of merchantability
   and fitness.  In no event shall the author be liable for any
   special, indirect or consequential damages or any damages
@@ -44,14 +44,21 @@ USB_ClassInfo_CDC_Host_t VirtualSerial_CDC_Interface =
        {
                .Config =
                        {
-                               .DataINPipeNumber           = 1,
-                               .DataINPipeDoubleBank       = false,
-
-                               .DataOUTPipeNumber          = 2,
-                               .DataOUTPipeDoubleBank      = false,
-
-                               .NotificationPipeNumber     = 3,
-                               .NotificationPipeDoubleBank = false,
+                               .DataINPipe             =
+                                       {
+                                               .Address        = (PIPE_DIR_IN  | 1),
+                                               .Banks          = 1,
+                                       },
+                               .DataOUTPipe            =
+                                       {
+                                               .Address        = (PIPE_DIR_OUT | 2),
+                                               .Banks          = 1,
+                                       },
+                               .NotificationPipe       =
+                                       {
+                                               .Address        = (PIPE_DIR_IN  | 3),
+                                               .Banks          = 1,
+                                       },
                        },
        };
 
@@ -62,11 +69,11 @@ USB_ClassInfo_CDC_Host_t VirtualSerial_CDC_Interface =
 int main(void)
 {
        SetupHardware();
-       
+
        puts_P(PSTR(ESC_FG_CYAN "CDC Host Demo running.\r\n" ESC_FG_WHITE));
 
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
-       sei();
+       GlobalInterruptEnable();
 
        for (;;)
        {
@@ -80,12 +87,14 @@ 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);
+#endif
 
        /* Hardware Initialization */
        Serial_Init(9600, false);
@@ -164,6 +173,18 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void)
                return;
        }
 
+       VirtualSerial_CDC_Interface.State.LineEncoding.BaudRateBPS = 9600;
+       VirtualSerial_CDC_Interface.State.LineEncoding.CharFormat  = CDC_LINEENCODING_OneStopBit;
+       VirtualSerial_CDC_Interface.State.LineEncoding.ParityType  = CDC_PARITY_None;
+       VirtualSerial_CDC_Interface.State.LineEncoding.DataBits    = 8;
+
+       if (CDC_Host_SetLineEncoding(&VirtualSerial_CDC_Interface))
+       {
+               puts_P(PSTR("Error Setting Device Line Encoding.\r\n"));
+               LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
+               return;
+       }
+
        puts_P(PSTR("CDC Device Enumerated.\r\n"));
        LEDs_SetAllLEDs(LEDMASK_USB_READY);
 }