aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/Magstripe
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-07-16 15:00:10 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-07-16 15:00:10 +0000
commitd6543dee0d2723ee9f09137116264f123433b1a3 (patch)
treecf63e2aa77808e2bdc6a9c52c7cdd99e2b76a279 /Projects/Magstripe
parentc619e21fa74d7ea225292ecf5d514d0b253ad0a8 (diff)
downloadlufa-d6543dee0d2723ee9f09137116264f123433b1a3.tar.gz
lufa-d6543dee0d2723ee9f09137116264f123433b1a3.tar.bz2
lufa-d6543dee0d2723ee9f09137116264f123433b1a3.zip
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).
Diffstat (limited to 'Projects/Magstripe')
-rw-r--r--Projects/Magstripe/Descriptors.c2
-rw-r--r--Projects/Magstripe/Magstripe.c10
-rw-r--r--Projects/Magstripe/Magstripe.h3
3 files changed, 10 insertions, 5 deletions
diff --git a/Projects/Magstripe/Descriptors.c b/Projects/Magstripe/Descriptors.c
index de704ae15..68c98ed34 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 95c81f342..1151735bd 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 1009e32e8..93e593e7c 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