3      Copyright (C) Dean Camera, 2009. 
   5   dean [at] fourwalledcubicle [dot] com 
   6       www.fourwalledcubicle.com 
  10   Copyright 2009  Denver Gingerich (denver [at] ossguy [dot] com) 
  11   Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  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. 
  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 
  34  *  Header file for Magstripe.c. 
  43                 #include <avr/interrupt.h> 
  47                 #include "Descriptors.h" 
  48                 #include "MagstripeHW.h" 
  49                 #include "CircularBitBuffer.h" 
  51                 #include <LUFA/Version.h>                    // Library Version Information 
  52                 #include <LUFA/Common/ButtLoadTag.h>         // PROGMEM tags readable by the ButtLoad project 
  53                 #include <LUFA/Drivers/USB/USB.h>            // USB Functionality 
  54                 #include <LUFA/Scheduler/Scheduler.h>        // Simple scheduler for task management 
  57         /* Task Definitions: */ 
  58                 /** Task definition for the keyboard and magnetic card reading task. */ 
  59                 TASK(USB_Keyboard_Report
); 
  64                 /** HID Class Specific Request to get the current HID report from the device. */ 
  65                 #define REQ_GetReport      0x01 
  67                 /** HID Class Specific Request to get the current device idle count. */ 
  68                 #define REQ_GetIdle        0x02 
  70                 /** HID Class Specific Request to set the current HID report to the device. */ 
  71                 #define REQ_SetReport      0x09 
  73                 /** HID Class Specific Request to set the device's idle count. */ 
  74                 #define REQ_SetIdle        0x0A 
  76                 /** HID Class Specific Request to get the current HID report protocol mode. */ 
  77                 #define REQ_GetProtocol    0x03 
  79                 /** HID Class Specific Request to set the current HID report protocol mode. */ 
  80                 #define REQ_SetProtocol    0x0B 
  82                 /** HID keyboard keycode to indicate that the "1" key is currently pressed. */ 
  85                 /** HID keyboard keycode to indicate that the "0" key is currently pressed. */ 
  88                 /** HID keyboard keycode to indicate that the enter key is currently pressed. */ 
  92                 /** Type define for the keyboard report structure. This structure matches the report layout 
  93                  *  given to the host in the HID Report descriptor, as well as matches the boot protocol report 
  94                  *  structure. This means that this one report structure can be used in both Report and Boot Protocol 
  98                         uint8_t Modifier
; /**< Modifier byte, indicating pressed modifier keys such as CTRL or ALT */ 
  99                         uint8_t Reserved
; /**< Reserved for OEM use, always set to 0 */ 
 100                         uint8_t KeyCode
[6]; /**< Key code array for pressed keys - up to six can be given simultaneously */ 
 101                 } USB_KeyboardReport_Data_t
; 
 103         /* Event Handlers: */ 
 104                 /** Indicates that this module will catch the USB_Connect event when thrown by the library. */ 
 105                 HANDLES_EVENT(USB_Connect
); 
 107                 /** Indicates that this module will catch the USB_Disconnect event when thrown by the library. */ 
 108                 HANDLES_EVENT(USB_Disconnect
); 
 110                 /** Indicates that this module will catch the USB_ConfigurationChanged event when thrown by the library. */ 
 111                 HANDLES_EVENT(USB_ConfigurationChanged
); 
 113                 /** Indicates that this module will catch the USB_UnhandledControlPacket event when thrown by the library. */ 
 114                 HANDLES_EVENT(USB_UnhandledControlPacket
); 
 116         /* Function Prototypes: */ 
 117                 bool GetNextReport(USB_KeyboardReport_Data_t
* ReportData
); 
 118                 void SendKey(USB_KeyboardReport_Data_t
* KeyboardReportData
, uint8_t Key
); 
 119                 void Send(USB_KeyboardReport_Data_t
* KeyboardReportData
, bool SendReport
);