Add new Audio Class Driver Host demos.
[pub/USBasp.git] / Demos / Host / LowLevel / KeyboardHost / KeyboardHost.c
index c35a903..6df052d 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2010.
+     Copyright (C) Dean Camera, 2011.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2011  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
@@ -66,9 +66,12 @@ void SetupHardware(void)
        clock_prescale_set(clock_div_1);
 
        /* Hardware Initialization */
-       SerialStream_Init(9600, false);
+       Serial_Init(9600, false);
        LEDs_Init();
        USB_Init();
+
+       /* Create a stdio stream for the serial port for stdin and stdout */
+       Serial_CreateStream(NULL);
 }
 
 /** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and
@@ -100,7 +103,7 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void)
 /** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */
 void EVENT_USB_Host_HostError(const uint8_t ErrorCode)
 {
-       USB_ShutDown();
+       USB_Disable();
 
        printf_P(PSTR(ESC_FG_RED "Host Mode Error\r\n"
                                 " -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode);
@@ -149,7 +152,7 @@ void ReadNextReport(void)
        if (Pipe_IsReadWriteAllowed())
        {
                /* Read in keyboard report data */
-               Pipe_Read_Stream_LE(&KeyboardReport, sizeof(KeyboardReport));
+               Pipe_Read_Stream_LE(&KeyboardReport, sizeof(KeyboardReport), NULL);
 
                /* Indicate if the modifier byte is non-zero (special key such as shift is being pressed) */
                LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0);
@@ -170,9 +173,13 @@ void ReadNextReport(void)
                                PressedKey = (KeyCode - HID_KEYBOARD_SC_A) + 'A';
                        }
                        else if ((KeyCode >= HID_KEYBOARD_SC_1_AND_EXCLAMATION) &
-                                        (KeyCode <= HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS))
+                                        (KeyCode  < HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS))
+                       {
+                               PressedKey = (KeyCode - HID_KEYBOARD_SC_1_AND_EXCLAMATION) + '1';
+                       }
+                       else if (KeyCode == HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS)
                        {
-                               PressedKey = (KeyCode - HID_KEYBOARD_SC_1_AND_EXCLAMATION) + '0';
+                               PressedKey = '0';
                        }
                        else if (KeyCode == HID_KEYBOARD_SC_SPACE)
                        {