Fixed minor issue with the RNDISEthernet demo DHCP protocol decoder routine using...
[pub/USBasp.git] / Projects / Magstripe / Magstripe.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Denver Gingerich (denver [at] ossguy [dot] com)
11 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
12
13 Permission to use, copy, modify, and distribute this software
14 and its documentation for any purpose and without fee is hereby
15 granted, provided that the above copyright notice appear in all
16 copies and that both that the copyright notice and this
17 permission notice and warranty disclaimer appear in supporting
18 documentation, and that the name of the author not be used in
19 advertising or publicity pertaining to distribution of the
20 software without specific, written prior permission.
21
22 The author disclaim all warranties with regard to this
23 software, including all implied warranties of merchantability
24 and fitness. In no event shall the author be liable for any
25 special, indirect or consequential damages or any damages
26 whatsoever resulting from loss of use, data or profits, whether
27 in an action of contract, negligence or other tortious action,
28 arising out of or in connection with the use or performance of
29 this software.
30 */
31
32 /** \file
33 *
34 * Header file for Magstripe.c.
35 */
36
37 #ifndef _MAGSTRIPE_H_
38 #define _MAGSTRIPE_H_
39
40 /* Includes: */
41 #include <avr/io.h>
42 #include <avr/wdt.h>
43 #include <avr/interrupt.h>
44 #include <avr/power.h>
45 #include <stdbool.h>
46 #include <string.h>
47
48 #include "Descriptors.h"
49 #include "MagstripeHW.h"
50 #include "CircularBitBuffer.h"
51
52 #include <LUFA/Version.h> // Library Version Information
53 #include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
54 #include <LUFA/Drivers/USB/USB.h> // USB Functionality
55 #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
56
57
58 /* Task Definitions: */
59 /** Task definition for the keyboard and magnetic card reading task. */
60 TASK(USB_Keyboard_Report);
61
62 TASK(Magstripe_Read);
63
64 /* Macros: */
65 /** HID Class Specific Request to get the current HID report from the device. */
66 #define REQ_GetReport 0x01
67
68 /** HID Class Specific Request to get the current device idle count. */
69 #define REQ_GetIdle 0x02
70
71 /** HID Class Specific Request to set the current HID report to the device. */
72 #define REQ_SetReport 0x09
73
74 /** HID Class Specific Request to set the device's idle count. */
75 #define REQ_SetIdle 0x0A
76
77 /** HID Class Specific Request to get the current HID report protocol mode. */
78 #define REQ_GetProtocol 0x03
79
80 /** HID Class Specific Request to set the current HID report protocol mode. */
81 #define REQ_SetProtocol 0x0B
82
83 /** HID keyboard keycode to indicate that the "1" key is currently pressed. */
84 #define KEY_1 30
85
86 /** HID keyboard keycode to indicate that the "0" key is currently pressed. */
87 #define KEY_0 39
88
89 /** HID keyboard keycode to indicate that the enter key is currently pressed. */
90 #define KEY_ENTER 40
91
92 /* Type Defines: */
93 /** Type define for the keyboard report structure. This structure matches the report layout
94 * given to the host in the HID Report descriptor, as well as matches the boot protocol report
95 * structure. This means that this one report structure can be used in both Report and Boot Protocol
96 * modes. */
97 typedef struct
98 {
99 uint8_t Modifier; /**< Modifier byte, indicating pressed modifier keys such as CTRL or ALT */
100 uint8_t Reserved; /**< Reserved for OEM use, always set to 0 */
101 uint8_t KeyCode; /**< Key code array for pressed keys - up to six can be given simultaneously */
102 } USB_KeyboardReport_Data_t;
103
104 /* Event Handlers: */
105 /** Indicates that this module will catch the USB_Connect event when thrown by the library. */
106 HANDLES_EVENT(USB_Connect);
107
108 /** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */
109 HANDLES_EVENT(USB_Disconnect);
110
111 /** Indicates that this module will catch the USB_ConfigurationChanged event when thrown by the library. */
112 HANDLES_EVENT(USB_ConfigurationChanged);
113
114 /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */
115 HANDLES_EVENT(USB_UnhandledControlPacket);
116
117 /* Function Prototypes: */
118 bool GetNextReport(USB_KeyboardReport_Data_t* ReportData);
119 void SendKey(USB_KeyboardReport_Data_t* KeyboardReportData, uint8_t Key);
120 void Send(USB_KeyboardReport_Data_t* KeyboardReportData, bool SendReport);
121
122 #endif