aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28>2009-07-16 15:00:10 +0000
committerDean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28>2009-07-16 15:00:10 +0000
commitc5c09212ecbc8f8290a2ae5c99c97a648af0dc2b (patch)
treecf63e2aa77808e2bdc6a9c52c7cdd99e2b76a279
parentde9a9be8c2ddaec38826fe7300be48489e426146 (diff)
Minor updates to the Magstripe and MissileLauncher projects to fix bugs and improve performance.
Fixed error in GenericHID descriptors preventing it from passing the USB-IF HID tests (thanks to Søren Greiner). git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@652 d5102386-fcda-11dd-9fdb-3debd5008f28
-rw-r--r--Demos/Device/ClassDriver/GenericHID/Descriptors.c4
-rw-r--r--LUFA/ManPages/ChangeLog.txt1
-rw-r--r--Projects/Magstripe/Descriptors.c2
-rw-r--r--Projects/Magstripe/Magstripe.c10
-rw-r--r--Projects/Magstripe/Magstripe.h3
-rw-r--r--Projects/MissileLauncher/MissileLauncher.c5
6 files changed, 16 insertions, 9 deletions
diff --git a/Demos/Device/ClassDriver/GenericHID/Descriptors.c b/Demos/Device/ClassDriver/GenericHID/Descriptors.c
index 0ce3c560..abc360bf 100644
--- a/Demos/Device/ClassDriver/GenericHID/Descriptors.c
+++ b/Demos/Device/ClassDriver/GenericHID/Descriptors.c
@@ -51,8 +51,8 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
0x09, 0x02, /* Usage (Vendor Defined) */
0x75, 0x08, /* Report Size (8) */
0x95, GENERIC_REPORT_SIZE, /* Report Count (GENERIC_REPORT_SIZE) */
- 0x15, 0x00, /* Logical Minimum (0) */
- 0x25, 0xff, /* Logical Maximum (255) */
+ 0x15, 0x80, /* Logical Minimum (-128) */
+ 0x25, 0x7F, /* Logical Maximum (127) */
0x81, 0x02, /* Input (Data, Variable, Absolute) */
0x09, 0x03, /* Usage (Vendor Defined) */
0x75, 0x08, /* Report Size (8) */
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt
index cbe4c59e..c2b7d5ed 100644
--- a/LUFA/ManPages/ChangeLog.txt
+++ b/LUFA/ManPages/ChangeLog.txt
@@ -60,6 +60,7 @@
* - Fixed USB Pad regulator not being disabled on some AVR models when the USB_OPT_REG_DISABLED option is used
* - Fixed Host mode to Device mode UID change not causing a USB Disconnect event when a device was connected
* - Fixed Mouse/Keyboard demos not performing the correct arithmetic on the Idle period at the right times (thanks to Brian Dickman)
+ * - Fixed GenericHID failing HID class tests due to incorrect Logical Minimum and Logical Maximum values (thanks to Søren Greiner)
*
*
* \section Sec_ChangeLog090605 Version 090605
diff --git a/Projects/Magstripe/Descriptors.c b/Projects/Magstripe/Descriptors.c
index de704ae1..68c98ed3 100644
--- a/Projects/Magstripe/Descriptors.c
+++ b/Projects/Magstripe/Descriptors.c
@@ -154,7 +154,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | KEYBOARD_EPNUM),
.Attributes = EP_TYPE_INTERRUPT,
.EndpointSize = KEYBOARD_EPSIZE,
- .PollingIntervalMS = 0x04
+ .PollingIntervalMS = 0x01
},
};
diff --git a/Projects/Magstripe/Magstripe.c b/Projects/Magstripe/Magstripe.c
index 95c81f34..1151735b 100644
--- a/Projects/Magstripe/Magstripe.c
+++ b/Projects/Magstripe/Magstripe.c
@@ -130,6 +130,7 @@ void ReadMagstripeData(void)
bool ClockPinLevel = ((Magstripe_LCL & TrackInfo[Track].ClockMask) != 0);
bool ClockLevelChanged = (((Magstripe_LCL ^ Magstripe_Prev) & TrackInfo[Track].ClockMask) != 0);
+ /* Sample on rising clock edges */
if (ClockPinLevel && ClockLevelChanged)
BitBuffer_StoreNextBit(&TrackDataBuffers[Track], DataPinLevel);
}
@@ -171,15 +172,15 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const H
static bool IsKeyReleaseReport;
static bool IsNewlineReport;
- BitBuffer_t* Buffer = NULL;
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
+ BitBuffer_t* Buffer = NULL;
- /* Key reports must be interleaved with 0 Key Code reports to release the keys, or repeated keys will be ignored */
+ /* Key reports must be interleaved with key release reports, or repeated keys will be ignored */
IsKeyReleaseReport = !IsKeyReleaseReport;
if (IsKeyReleaseReport)
{
- KeyboardReport->KeyCode = 0;
+ KeyboardReport->KeyCode = KEY_NONE;
}
else if (IsNewlineReport)
{
@@ -188,6 +189,7 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const H
}
else
{
+ /* Read out tracks in ascending order - when each track buffer is empty, progress to next buffer */
if (TrackDataBuffers[0].Elements)
Buffer = &TrackDataBuffers[0];
else if (TrackDataBuffers[1].Elements)
@@ -199,7 +201,7 @@ uint16_t CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const H
KeyboardReport->KeyCode = BitBuffer_GetNextBit(Buffer) ? KEY_1 : KEY_0;
- /* If buffer now empty, next report must be a newline to seperate track data */
+ /* If current track buffer now empty, next report must be a newline to seperate track data */
if (!(Buffer->Elements))
IsNewlineReport = true;
}
diff --git a/Projects/Magstripe/Magstripe.h b/Projects/Magstripe/Magstripe.h
index 1009e32e..93e593e7 100644
--- a/Projects/Magstripe/Magstripe.h
+++ b/Projects/Magstripe/Magstripe.h
@@ -51,6 +51,9 @@
#include <LUFA/Drivers/USB/Class/HID.h>
/* Macros: */
+ /** HID keyboard keycode to indicate that no is currently pressed. */
+ #define KEY_NONE 0
+
/** HID keyboard keycode to indicate that the "1" key is currently pressed. */
#define KEY_1 30
diff --git a/Projects/MissileLauncher/MissileLauncher.c b/Projects/MissileLauncher/MissileLauncher.c
index 046c132f..88902cf2 100644
--- a/Projects/MissileLauncher/MissileLauncher.c
+++ b/Projects/MissileLauncher/MissileLauncher.c
@@ -137,8 +137,9 @@ void SetupHardware(void)
void Read_Joystick_Status(void)
{
uint8_t JoyStatus_LCL = Joystick_GetStatus();
+ uint8_t Buttons_LCL = Buttons_GetStatus();
- if (BUTTONS_BUTTON1 && Buttons_GetStatus())
+ if (Buttons_LCL & BUTTONS_BUTTON1)
Send_Command(CMD_FIRE);
else if (JoyStatus_LCL & JOY_UP)
Send_Command(CMD_UP);
@@ -285,7 +286,7 @@ void WriteNextReport(uint8_t* ReportOUTData, uint16_t ReportLength)
/* Class specific request to send a HID report to the device */
USB_ControlRequest = (USB_Request_Header_t)
{
- .bmRequestType = 0x21,
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
.bRequest = 0x09,
.wValue = 0x02,
.wIndex = 0x01,