Add ASF provider manifest file and adjust VSIX packing to compress the library contents.
[pub/USBasp.git] / Demos / Device / LowLevel / Keyboard / Keyboard.c
index 260d091..6b54279 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2011.
+     Copyright (C) Dean Camera, 2013.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2013  Dean Camera (dean [at] fourwalledcubicle [dot] com)
   Copyright 2010  Denver Gingerich (denver [at] ossguy [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
@@ -19,7 +19,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
@@ -62,7 +62,7 @@ int main(void)
        SetupHardware();
 
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
-       sei();
+       GlobalInterruptEnable();
 
        for (;;)
        {
@@ -117,10 +117,8 @@ void EVENT_USB_Device_ConfigurationChanged(void)
        bool ConfigSuccess = true;
 
        /* Setup HID Report Endpoints */
-       ConfigSuccess &= Endpoint_ConfigureEndpoint(KEYBOARD_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
-                                                   KEYBOARD_EPSIZE, ENDPOINT_BANK_SINGLE);
-       ConfigSuccess &= Endpoint_ConfigureEndpoint(KEYBOARD_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
-                                                   KEYBOARD_EPSIZE, ENDPOINT_BANK_SINGLE);
+       ConfigSuccess &= Endpoint_ConfigureEndpoint(KEYBOARD_IN_EPADDR, EP_TYPE_INTERRUPT, KEYBOARD_EPSIZE, 1);
+       ConfigSuccess &= Endpoint_ConfigureEndpoint(KEYBOARD_OUT_EPADDR, EP_TYPE_INTERRUPT, KEYBOARD_EPSIZE, 1);
 
        /* Turn on Start-of-Frame events for tracking HID report period expiry */
        USB_Device_EnableSOFEvents();
@@ -296,14 +294,11 @@ void SendNextReport(void)
 {
        static USB_KeyboardReport_Data_t PrevKeyboardReportData;
        USB_KeyboardReport_Data_t        KeyboardReportData;
-       bool                             SendReport = true;
+       bool                             SendReport = false;
 
        /* Create the next keyboard report for transmission to the host */
        CreateKeyboardReport(&KeyboardReportData);
 
-       /* Check to see if the report data has changed - if so a report MUST be sent */
-       SendReport = (memcmp(&PrevKeyboardReportData, &KeyboardReportData, sizeof(USB_KeyboardReport_Data_t)) != 0);
-
        /* Check if the idle period is set and has elapsed */
        if (IdleCount && (!(IdleMSRemaining)))
        {
@@ -313,9 +308,14 @@ void SendNextReport(void)
                /* Idle period is set and has elapsed, must send a report to the host */
                SendReport = true;
        }
+       else
+       {
+               /* Check to see if the report data has changed - if so a report MUST be sent */
+               SendReport = (memcmp(&PrevKeyboardReportData, &KeyboardReportData, sizeof(USB_KeyboardReport_Data_t)) != 0);    
+       }
 
        /* Select the Keyboard Report Endpoint */
-       Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM);
+       Endpoint_SelectEndpoint(KEYBOARD_IN_EPADDR);
 
        /* Check if Keyboard Endpoint Ready for Read/Write and if we should send a new report */
        if (Endpoint_IsReadWriteAllowed() && SendReport)
@@ -335,7 +335,7 @@ void SendNextReport(void)
 void ReceiveNextReport(void)
 {
        /* Select the Keyboard LED Report Endpoint */
-       Endpoint_SelectEndpoint(KEYBOARD_OUT_EPNUM);
+       Endpoint_SelectEndpoint(KEYBOARD_OUT_EPADDR);
 
        /* Check if Keyboard LED Endpoint contains a packet */
        if (Endpoint_IsOUTReceived())