aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host/KeyboardHost
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-04-16 08:50:34 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-04-16 08:50:34 +0000
commit8f6b4ddf764c3a54e42d00a7502c82c5c3e71b1c (patch)
tree65c37548f19c26de3971639067d6f290095f5843 /Demos/Host/KeyboardHost
parentef06bfd1c0ef5272c32808e23d0fd60d2d1bca9c (diff)
downloadlufa-8f6b4ddf764c3a54e42d00a7502c82c5c3e71b1c.tar.gz
lufa-8f6b4ddf764c3a54e42d00a7502c82c5c3e71b1c.tar.bz2
lufa-8f6b4ddf764c3a54e42d00a7502c82c5c3e71b1c.zip
Fixed GenericHIDHost demo report write routine incorrect for control type requests (thanks to Andrei Krainev).
Removed Endpoint_ClearCurrentBank() and Pipe_ClearCurrentBank() in favour of new Endpoint_ClearIN(), Endpoint_ClearOUT(), Endpoint_ClearControlIN(), Endpoint_ClearControlOUT(), Pipe_ClearIN(), Pipe_ClearOUT(), Pipe_ClearControlIN() and Pipe_ClearControlOUT() macros (done to allow for the detection of packets of zero length). Renamed *_ReadWriteAllowed() macros to *_IsReadWriteAllowed() to remain consistent with the rest of the LUFA API. Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived(), Endpoint_ClearSetupReceived() macro has been renamed to Endpoint_ClearControlSETUP(), the Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent() and the Pipe_ClearSetupSent() macro is no longer applicable and should be removed - changes made to compliment the new endpoint and pipe bank management API. Updated all demos, bootloaders and projects to use the new endpoint and pipe management APIs (thanks to Roman Thiel). Updated library doxygen documentation, added groups, changed documentation macro functions to real functions for clarity. Removed old endpoint and pipe aliased read/write/discard routines which did not have an explicit endian specifier for clarity. Removed the ButtLoadTag.h header file, as no one used for its intended purpose anyway.
Diffstat (limited to 'Demos/Host/KeyboardHost')
-rw-r--r--Demos/Host/KeyboardHost/ConfigDescriptor.h1
-rw-r--r--Demos/Host/KeyboardHost/KeyboardHost.c83
-rw-r--r--Demos/Host/KeyboardHost/KeyboardHost.h1
3 files changed, 41 insertions, 44 deletions
diff --git a/Demos/Host/KeyboardHost/ConfigDescriptor.h b/Demos/Host/KeyboardHost/ConfigDescriptor.h
index 1d168b453..416315b97 100644
--- a/Demos/Host/KeyboardHost/ConfigDescriptor.h
+++ b/Demos/Host/KeyboardHost/ConfigDescriptor.h
@@ -38,7 +38,6 @@
/* Includes: */
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
- #include <LUFA/Drivers/USB/Class/ConfigDescriptor.h> // Configuration Descriptor Parser
#include "KeyboardHost.h"
diff --git a/Demos/Host/KeyboardHost/KeyboardHost.c b/Demos/Host/KeyboardHost/KeyboardHost.c
index 947f23281..35055ca79 100644
--- a/Demos/Host/KeyboardHost/KeyboardHost.c
+++ b/Demos/Host/KeyboardHost/KeyboardHost.c
@@ -36,12 +36,6 @@
#include "KeyboardHost.h"
-/* Project Tags, for reading out using the ButtLoad project */
-BUTTLOADTAG(ProjName, "LUFA KBD Host App");
-BUTTLOADTAG(BuildTime, __TIME__);
-BUTTLOADTAG(BuildDate, __DATE__);
-BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
-
/* Scheduler Task List */
TASK_LIST
{
@@ -191,52 +185,57 @@ void ReadNextReport(void)
Pipe_Unfreeze();
#endif
- /* Ensure pipe contains data and is ready to be read before continuing */
- if (!(Pipe_ReadWriteAllowed()))
+ /* Check to see if a packet has been received */
+ if (!(Pipe_IsINReceived()))
{
#if !defined(INTERRUPT_DATA_PIPE)
- /* Refreeze keyboard data pipe */
+ /* Refreeze HID data IN pipe */
Pipe_Freeze();
#endif
-
+
return;
}
- /* Read in keyboard report data */
- Pipe_Read_Stream_LE(&KeyboardReport, sizeof(KeyboardReport));
-
- /* Clear the IN endpoint, ready for next data packet */
- Pipe_ClearCurrentBank();
-
- /* 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);
-
- /* Check if a key has been pressed */
- if (KeyboardReport.KeyCode)
+ /* Ensure pipe contains data before trying to read from it */
+ if (Pipe_IsReadWriteAllowed())
{
- /* Toggle status LED to indicate keypress */
- if (LEDs_GetLEDs() & LEDS_LED2)
- LEDs_TurnOffLEDs(LEDS_LED2);
- else
- LEDs_TurnOnLEDs(LEDS_LED2);
-
- char PressedKey = 0;
-
- /* Retrieve pressed key character if alphanumeric */
- if ((KeyboardReport.KeyCode >= 0x04) && (KeyboardReport.KeyCode <= 0x1D))
- PressedKey = (KeyboardReport.KeyCode - 0x04) + 'A';
- else if ((KeyboardReport.KeyCode >= 0x1E) && (KeyboardReport.KeyCode <= 0x27))
- PressedKey = (KeyboardReport.KeyCode - 0x1E) + '0';
- else if (KeyboardReport.KeyCode == 0x2C)
- PressedKey = ' ';
- else if (KeyboardReport.KeyCode == 0x28)
- PressedKey = '\n';
-
- /* Print the pressed key character out through the serial port if valid */
- if (PressedKey)
- putchar(PressedKey);
+ /* Read in keyboard report data */
+ Pipe_Read_Stream_LE(&KeyboardReport, sizeof(KeyboardReport));
+
+ /* 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);
+
+ /* Check if a key has been pressed */
+ if (KeyboardReport.KeyCode)
+ {
+ /* Toggle status LED to indicate keypress */
+ if (LEDs_GetLEDs() & LEDS_LED2)
+ LEDs_TurnOffLEDs(LEDS_LED2);
+ else
+ LEDs_TurnOnLEDs(LEDS_LED2);
+
+ char PressedKey = 0;
+
+ /* Retrieve pressed key character if alphanumeric */
+ if ((KeyboardReport.KeyCode >= 0x04) && (KeyboardReport.KeyCode <= 0x1D))
+ PressedKey = (KeyboardReport.KeyCode - 0x04) + 'A';
+ else if ((KeyboardReport.KeyCode >= 0x1E) && (KeyboardReport.KeyCode <= 0x27))
+ PressedKey = (KeyboardReport.KeyCode - 0x1E) + '0';
+ else if (KeyboardReport.KeyCode == 0x2C)
+ PressedKey = ' ';
+ else if (KeyboardReport.KeyCode == 0x28)
+ PressedKey = '\n';
+
+ /* Print the pressed key character out through the serial port if valid */
+ if (PressedKey)
+ putchar(PressedKey);
+ }
}
+
+ /* Clear the IN endpoint, ready for next data packet */
+ Pipe_ClearIN();
+
#if !defined(INTERRUPT_DATA_PIPE)
/* Refreeze keyboard data pipe */
Pipe_Freeze();
diff --git a/Demos/Host/KeyboardHost/KeyboardHost.h b/Demos/Host/KeyboardHost/KeyboardHost.h
index 8c1a70915..2c541f6a5 100644
--- a/Demos/Host/KeyboardHost/KeyboardHost.h
+++ b/Demos/Host/KeyboardHost/KeyboardHost.h
@@ -45,7 +45,6 @@
#include <stdio.h>
#include <LUFA/Version.h> // Library Version Information
- #include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/Misc/TerminalCodes.h> // ANSI Terminal Escape Codes
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver