Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lufa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Erik Strand
lufa
Commits
8bc3a91c
Commit
8bc3a91c
authored
16 years ago
by
Dean Camera
Browse files
Options
Downloads
Patches
Plain Diff
Fix broken MagStripe project.
parent
d475ea43
Loading
Loading
Loading
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Projects/Magstripe/Magstripe.c
+21
-13
21 additions, 13 deletions
Projects/Magstripe/Magstripe.c
Projects/Magstripe/Magstripe.h
+5
-5
5 additions, 5 deletions
Projects/Magstripe/Magstripe.h
with
26 additions
and
18 deletions
Projects/Magstripe/Magstripe.c
+
21
−
13
View file @
8bc3a91c
...
@@ -47,6 +47,8 @@ BitBuffer_t TrackDataBuffers[3];
...
@@ -47,6 +47,8 @@ BitBuffer_t TrackDataBuffers[3];
* within a device can be differentiated from one another.
* within a device can be differentiated from one another.
*/
*/
USB_ClassInfo_HID_Device_t
Keyboard_HID_Interface
=
USB_ClassInfo_HID_Device_t
Keyboard_HID_Interface
=
{
.
Config
=
{
{
.
InterfaceNumber
=
0
,
.
InterfaceNumber
=
0
,
...
@@ -54,6 +56,12 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
...
@@ -54,6 +56,12 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
.
ReportINEndpointSize
=
KEYBOARD_EPSIZE
,
.
ReportINEndpointSize
=
KEYBOARD_EPSIZE
,
.
ReportINBufferSize
=
sizeof
(
USB_KeyboardReport_Data_t
),
.
ReportINBufferSize
=
sizeof
(
USB_KeyboardReport_Data_t
),
},
.
State
=
{
// Leave all state values to their defaults
}
};
};
/** Main program entry point. This routine contains the overall program flow, including initial
/** Main program entry point. This routine contains the overall program flow, including initial
...
@@ -71,7 +79,7 @@ int main(void)
...
@@ -71,7 +79,7 @@ int main(void)
if
(
Magstripe_GetStatus
()
&
MAG_CARDPRESENT
)
if
(
Magstripe_GetStatus
()
&
MAG_CARDPRESENT
)
ReadMagstripeData
();
ReadMagstripeData
();
USB_HID
_USBTask
(
&
Keyboard_HID_Interface
);
HID_Device
_USBTask
(
&
Keyboard_HID_Interface
);
USB_USBTask
();
USB_USBTask
();
}
}
}
}
...
@@ -134,20 +142,20 @@ void ReadMagstripeData(void)
...
@@ -134,20 +142,20 @@ void ReadMagstripeData(void)
/** Event handler for the library USB Configuration Changed event. */
/** Event handler for the library USB Configuration Changed event. */
void
EVENT_USB_ConfigurationChanged
(
void
)
void
EVENT_USB_ConfigurationChanged
(
void
)
{
{
USB_HID
_ConfigureEndpoints
(
&
Keyboard_HID_Interface
);
HID_Device
_ConfigureEndpoints
(
&
Keyboard_HID_Interface
);
}
}
/** Event handler for the library USB Unhandled Control Packet event. */
/** Event handler for the library USB Unhandled Control Packet event. */
void
EVENT_USB_UnhandledControlPacket
(
void
)
void
EVENT_USB_UnhandledControlPacket
(
void
)
{
{
USB_HID
_ProcessControlPacket
(
&
Keyboard_HID_Interface
);
HID_Device
_ProcessControlPacket
(
&
Keyboard_HID_Interface
);
}
}
/** Timer 0 CTC ISR, firing once each millisecond to keep track of elapsed idle time in the HID interface. */
/** Timer 0 CTC ISR, firing once each millisecond to keep track of elapsed idle time in the HID interface. */
ISR
(
TIMER0_COMPA_vect
,
ISR_BLOCK
)
ISR
(
TIMER0_COMPA_vect
,
ISR_BLOCK
)
{
{
if
(
Keyboard_HID_Interface
.
IdleMSRemaining
)
if
(
Keyboard_HID_Interface
.
State
.
IdleMSRemaining
)
Keyboard_HID_Interface
.
IdleMSRemaining
--
;
Keyboard_HID_Interface
.
State
.
IdleMSRemaining
--
;
}
}
/** HID Class driver callback function for the creation of a HID report for the host.
/** HID Class driver callback function for the creation of a HID report for the host.
...
@@ -158,7 +166,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
...
@@ -158,7 +166,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
*
*
* \return Number of bytes in the created report
* \return Number of bytes in the created report
*/
*/
uint16_t
CALLBACK_
USB_HID
_Create
Next
HIDReport
(
USB_ClassInfo_HID_Device_t
*
HIDInterfaceInfo
,
uint8_t
*
ReportID
,
void
*
ReportData
)
uint16_t
CALLBACK_
HID_Device
_CreateHIDReport
(
USB_ClassInfo_HID_Device_t
*
HIDInterfaceInfo
,
uint8_t
*
ReportID
,
void
*
ReportData
)
{
{
static
bool
IsKeyReleaseReport
;
static
bool
IsKeyReleaseReport
;
static
bool
IsNewlineReport
;
static
bool
IsNewlineReport
;
...
@@ -206,7 +214,7 @@ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_Device_t* HIDInt
...
@@ -206,7 +214,7 @@ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_Device_t* HIDInt
* \param ReportData Pointer to the report buffer where the received report is stored
* \param ReportData Pointer to the report buffer where the received report is stored
* \param ReportSize Size in bytes of the report received from the host
* \param ReportSize Size in bytes of the report received from the host
*/
*/
void
CALLBACK_
USB_HID_ProcessReceived
HIDReport
(
USB_ClassInfo_HID_Device_t
*
HIDInterfaceInfo
,
uint8_t
ReportID
,
void
CALLBACK_
HID_Device_Process
HIDReport
(
USB_ClassInfo_HID_Device_t
*
HIDInterfaceInfo
,
uint8_t
ReportID
,
void
*
ReportData
,
uint16_t
ReportSize
)
void
*
ReportData
,
uint16_t
ReportSize
)
{
{
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
...
...
This diff is collapsed.
Click to expand it.
Projects/Magstripe/Magstripe.h
+
5
−
5
View file @
8bc3a91c
...
@@ -79,9 +79,9 @@
...
@@ -79,9 +79,9 @@
void
EVENT_USB_ConfigurationChanged
(
void
);
void
EVENT_USB_ConfigurationChanged
(
void
);
void
EVENT_USB_UnhandledControlPacket
(
void
);
void
EVENT_USB_UnhandledControlPacket
(
void
);
uint16_t
CALLBACK_
USB_HID
_Create
Next
HIDReport
(
USB_ClassInfo_HID_t
*
HIDInterfaceInfo
,
uint8_t
*
ReportID
,
uint16_t
CALLBACK_
HID_Device
_CreateHIDReport
(
USB_ClassInfo_HID_
Device_
t
*
HIDInterfaceInfo
,
uint8_t
*
ReportID
,
void
*
ReportData
);
void
*
ReportData
);
void
CALLBACK_
USB_HID_ProcessReceived
HIDReport
(
USB_ClassInfo_HID_t
*
HIDInterfaceInfo
,
uint8_t
ReportID
,
void
CALLBACK_
HID_Device_Process
HIDReport
(
USB_ClassInfo_HID_
Device_
t
*
HIDInterfaceInfo
,
uint8_t
ReportID
,
void
*
ReportData
,
uint16_t
ReportSize
);
void
*
ReportData
,
uint16_t
ReportSize
);
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment