Add svn:eol-style property to source files, so that the line endings are correctly converted to the target system's native end of line style.
This commit is contained in:
parent
e331b531c6
commit
071e02c6b6
839 changed files with 274562 additions and 274562 deletions
|
@ -1,247 +1,247 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
/** HID report descriptor. This is a HID class specific descriptor, which defines the structure of the
|
||||
* reports sent and received by the HID device to and from the USB host. It indicates what data is sent,
|
||||
* where in the report each element is located and exactly how the data should be interpreted and used.
|
||||
*
|
||||
* See the HID class specification for more information on HID report descriptors.
|
||||
*/
|
||||
USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
|
||||
{
|
||||
0x05, 0x01, /* Usage Page (Generic Desktop) */
|
||||
0x09, 0x06, /* Usage (Keyboard) */
|
||||
0xa1, 0x01, /* Collection (Application) */
|
||||
0x05, 0x07, /* Usage Page (Key Codes) */
|
||||
0x19, 0xe0, /* Usage Minimum (Keyboard LeftControl) */
|
||||
0x29, 0xe7, /* Usage Maximum (Keyboard Right GUI) */
|
||||
0x15, 0x00, /* Logical Minimum (0) */
|
||||
0x25, 0x01, /* Logical Maximum (1) */
|
||||
0x75, 0x01, /* Report Size (1) */
|
||||
0x95, 0x08, /* Report Count (8) */
|
||||
0x81, 0x02, /* Input (Data, Variable, Absolute) */
|
||||
0x95, 0x01, /* Report Count (1) */
|
||||
0x75, 0x08, /* Report Size (8) */
|
||||
0x81, 0x03, /* Input (Const, Variable, Absolute) */
|
||||
0x95, 0x01, /* Report Count (1) */
|
||||
0x75, 0x08, /* Report Size (8) */
|
||||
0x15, 0x00, /* Logical Minimum (0) */
|
||||
0x25, 0x65, /* Logical Maximum (101) */
|
||||
0x05, 0x07, /* Usage Page (Keyboard) */
|
||||
0x19, 0x00, /* Usage Minimum (Reserved (no event indicated)) */
|
||||
0x29, 0x65, /* Usage Maximum (Keyboard Application) */
|
||||
0x81, 0x00, /* Input (Data, Array, Absolute) */
|
||||
0xc0 /* End Collection */
|
||||
};
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
*/
|
||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = 0x00,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2042,
|
||||
.ReleaseNumber = 0x0000,
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.HID_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0x00,
|
||||
.AlternateSetting = 0x00,
|
||||
|
||||
.TotalEndpoints = 1,
|
||||
|
||||
.Class = 0x03,
|
||||
.SubClass = 0x01,
|
||||
.Protocol = 0x01,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.HID_KeyboardHID =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_HID_Descriptor_t), .Type = DTYPE_HID},
|
||||
|
||||
.HIDSpec = VERSION_BCD(01.11),
|
||||
.CountryCode = 0x00,
|
||||
.TotalReportDescriptors = 1,
|
||||
.HIDReportType = DTYPE_Report,
|
||||
.HIDReportLength = sizeof(KeyboardReport)
|
||||
},
|
||||
|
||||
.HID_ReportINEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | KEYBOARD_EPNUM),
|
||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = KEYBOARD_EPSIZE,
|
||||
.PollingIntervalMS = 0x01
|
||||
},
|
||||
};
|
||||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors. */
|
||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
|
||||
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(32), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"Dean Camera and Denver Gingerich"
|
||||
};
|
||||
|
||||
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
||||
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(20), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"Magnetic Card Reader"
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
||||
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
|
||||
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
||||
* USB host.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
||||
{
|
||||
const uint8_t DescriptorType = (wValue >> 8);
|
||||
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
||||
|
||||
void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
Address = (void*)&DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
Address = (void*)&ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
Address = (void*)&LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
Address = (void*)&ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
Address = (void*)&ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case DTYPE_HID:
|
||||
Address = (void*)&ConfigurationDescriptor.HID_KeyboardHID;
|
||||
Size = sizeof(USB_HID_Descriptor_t);
|
||||
break;
|
||||
case DTYPE_Report:
|
||||
Address = (void*)&KeyboardReport;
|
||||
Size = sizeof(KeyboardReport);
|
||||
break;
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
/** HID report descriptor. This is a HID class specific descriptor, which defines the structure of the
|
||||
* reports sent and received by the HID device to and from the USB host. It indicates what data is sent,
|
||||
* where in the report each element is located and exactly how the data should be interpreted and used.
|
||||
*
|
||||
* See the HID class specification for more information on HID report descriptors.
|
||||
*/
|
||||
USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
|
||||
{
|
||||
0x05, 0x01, /* Usage Page (Generic Desktop) */
|
||||
0x09, 0x06, /* Usage (Keyboard) */
|
||||
0xa1, 0x01, /* Collection (Application) */
|
||||
0x05, 0x07, /* Usage Page (Key Codes) */
|
||||
0x19, 0xe0, /* Usage Minimum (Keyboard LeftControl) */
|
||||
0x29, 0xe7, /* Usage Maximum (Keyboard Right GUI) */
|
||||
0x15, 0x00, /* Logical Minimum (0) */
|
||||
0x25, 0x01, /* Logical Maximum (1) */
|
||||
0x75, 0x01, /* Report Size (1) */
|
||||
0x95, 0x08, /* Report Count (8) */
|
||||
0x81, 0x02, /* Input (Data, Variable, Absolute) */
|
||||
0x95, 0x01, /* Report Count (1) */
|
||||
0x75, 0x08, /* Report Size (8) */
|
||||
0x81, 0x03, /* Input (Const, Variable, Absolute) */
|
||||
0x95, 0x01, /* Report Count (1) */
|
||||
0x75, 0x08, /* Report Size (8) */
|
||||
0x15, 0x00, /* Logical Minimum (0) */
|
||||
0x25, 0x65, /* Logical Maximum (101) */
|
||||
0x05, 0x07, /* Usage Page (Keyboard) */
|
||||
0x19, 0x00, /* Usage Minimum (Reserved (no event indicated)) */
|
||||
0x29, 0x65, /* Usage Maximum (Keyboard Application) */
|
||||
0x81, 0x00, /* Input (Data, Array, Absolute) */
|
||||
0xc0 /* End Collection */
|
||||
};
|
||||
|
||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||
* device characteristics, including the supported USB version, control endpoint size and the
|
||||
* number of device configurations. The descriptor is read out by the USB host when the enumeration
|
||||
* process begins.
|
||||
*/
|
||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = 0x00,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2042,
|
||||
.ReleaseNumber = 0x0000,
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
/** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage
|
||||
* of the device in one of its supported configurations, including information about any device interfaces
|
||||
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
|
||||
* a configuration so that the host may correctly communicate with the USB device.
|
||||
*/
|
||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.HID_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0x00,
|
||||
.AlternateSetting = 0x00,
|
||||
|
||||
.TotalEndpoints = 1,
|
||||
|
||||
.Class = 0x03,
|
||||
.SubClass = 0x01,
|
||||
.Protocol = 0x01,
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.HID_KeyboardHID =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_HID_Descriptor_t), .Type = DTYPE_HID},
|
||||
|
||||
.HIDSpec = VERSION_BCD(01.11),
|
||||
.CountryCode = 0x00,
|
||||
.TotalReportDescriptors = 1,
|
||||
.HIDReportType = DTYPE_Report,
|
||||
.HIDReportLength = sizeof(KeyboardReport)
|
||||
},
|
||||
|
||||
.HID_ReportINEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | KEYBOARD_EPNUM),
|
||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = KEYBOARD_EPSIZE,
|
||||
.PollingIntervalMS = 0x01
|
||||
},
|
||||
};
|
||||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors. */
|
||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
/** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable
|
||||
* form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(32), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"Dean Camera and Denver Gingerich"
|
||||
};
|
||||
|
||||
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
||||
* and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
|
||||
* Descriptor.
|
||||
*/
|
||||
USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(20), .Type = DTYPE_String},
|
||||
|
||||
.UnicodeString = L"Magnetic Card Reader"
|
||||
};
|
||||
|
||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||
* documentation) by the application code so that the address and size of a requested descriptor can be given
|
||||
* to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function
|
||||
* is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the
|
||||
* USB host.
|
||||
*/
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
||||
{
|
||||
const uint8_t DescriptorType = (wValue >> 8);
|
||||
const uint8_t DescriptorNumber = (wValue & 0xFF);
|
||||
|
||||
void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
Address = (void*)&DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
Address = (void*)&ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
Address = (void*)&LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
Address = (void*)&ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
Address = (void*)&ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
case DTYPE_HID:
|
||||
Address = (void*)&ConfigurationDescriptor.HID_KeyboardHID;
|
||||
Size = sizeof(USB_HID_Descriptor_t);
|
||||
break;
|
||||
case DTYPE_Report:
|
||||
Address = (void*)&KeyboardReport;
|
||||
Size = sizeof(KeyboardReport);
|
||||
break;
|
||||
}
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
|
|
@ -1,70 +1,70 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for Descriptors.c.
|
||||
*/
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config; /**< Configuration descriptor header structure */
|
||||
USB_Descriptor_Interface_t HID_Interface; /**< Keyboard interface descriptor */
|
||||
USB_HID_Descriptor_t HID_KeyboardHID; /**< Keyboard HID descriptor */
|
||||
USB_Descriptor_Endpoint_t HID_ReportINEndpoint; /**< Keyboard key report endpoint descriptor */
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint number of the keyboard key press reporting endpoint. */
|
||||
#define KEYBOARD_EPNUM 1
|
||||
|
||||
/** Size of the keyboard report endpoints, in bytes. */
|
||||
#define KEYBOARD_EPSIZE 8
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for Descriptors.c.
|
||||
*/
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config; /**< Configuration descriptor header structure */
|
||||
USB_Descriptor_Interface_t HID_Interface; /**< Keyboard interface descriptor */
|
||||
USB_HID_Descriptor_t HID_KeyboardHID; /**< Keyboard HID descriptor */
|
||||
USB_Descriptor_Endpoint_t HID_ReportINEndpoint; /**< Keyboard key report endpoint descriptor */
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint number of the keyboard key press reporting endpoint. */
|
||||
#define KEYBOARD_EPNUM 1
|
||||
|
||||
/** Size of the keyboard report endpoints, in bytes. */
|
||||
#define KEYBOARD_EPSIZE 8
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,113 +1,113 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** Circular bit buffer library. This will allow for individual bits
|
||||
* to be stored in packed form inside circular buffers, to reduce
|
||||
* overall RAM usage.
|
||||
*/
|
||||
|
||||
#include "CircularBitBuffer.h"
|
||||
|
||||
/** Function to initialize or reset a bit buffer, ready for data to be stored into it. */
|
||||
void BitBuffer_Init(BitBuffer_t* const Buffer)
|
||||
{
|
||||
/* Reset the number of stored bits in the buffer */
|
||||
Buffer->Elements = 0;
|
||||
|
||||
/* Reset the data in and out pointer structures in the buffer to the first buffer bit */
|
||||
Buffer->In.CurrentByte = Buffer->Data;
|
||||
Buffer->In.ByteMask = (1 << 0);
|
||||
Buffer->Out.CurrentByte = Buffer->Data;
|
||||
Buffer->Out.ByteMask = (1 << 0);
|
||||
}
|
||||
|
||||
/** Function to store the given bit into the given bit buffer. */
|
||||
void BitBuffer_StoreNextBit(BitBuffer_t* const Buffer, const bool Bit)
|
||||
{
|
||||
/* If the bit to store is true, set the next bit in the buffer */
|
||||
if (Bit)
|
||||
*Buffer->In.CurrentByte |= Buffer->In.ByteMask;
|
||||
|
||||
/* Increment the number of stored bits in the buffer counter */
|
||||
Buffer->Elements++;
|
||||
|
||||
/* Check if the current buffer byte is full of stored bits */
|
||||
if (Buffer->In.ByteMask == (1 << 7))
|
||||
{
|
||||
/* Check if the end of the buffer has been reached, if so reset to start of buffer, otherwise advance to next bit */
|
||||
if (Buffer->In.CurrentByte != &Buffer->Data[sizeof(Buffer->Data) - 1])
|
||||
Buffer->In.CurrentByte++;
|
||||
else
|
||||
Buffer->In.CurrentByte = Buffer->Data;
|
||||
|
||||
/* Reset the storage bit mask in the current buffer byte to the first bit */
|
||||
Buffer->In.ByteMask = (1 << 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Shift the current storage bit mask to the next bit in the current byte */
|
||||
Buffer->In.ByteMask <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/** Function to retrieve the next bit stored in the given bit buffer. */
|
||||
bool BitBuffer_GetNextBit(BitBuffer_t* const Buffer)
|
||||
{
|
||||
/* Retrieve the value of the next bit stored in the buffer */
|
||||
bool Bit = ((*Buffer->Out.CurrentByte & Buffer->Out.ByteMask) != 0);
|
||||
|
||||
/* Clear the buffer bit */
|
||||
*Buffer->Out.CurrentByte &= ~Buffer->Out.ByteMask;
|
||||
|
||||
/* Decrement the number of stored bits in the buffer counter */
|
||||
Buffer->Elements--;
|
||||
|
||||
/* Check if the current buffer byte is empty of stored bits */
|
||||
if (Buffer->Out.ByteMask == (1 << 7))
|
||||
{
|
||||
/* Check if the end of the buffer has been reached, if so reset to start of buffer, otherwise advance to next bit */
|
||||
if (Buffer->Out.CurrentByte != &Buffer->Data[sizeof(Buffer->Data) - 1])
|
||||
Buffer->Out.CurrentByte++;
|
||||
else
|
||||
Buffer->Out.CurrentByte = Buffer->Data;
|
||||
|
||||
/* Reset the retrieval bit mask in the current buffer byte to the first bit */
|
||||
Buffer->Out.ByteMask = (1 << 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Shift the current retrieval bit mask to the next bit in the current byte */
|
||||
Buffer->Out.ByteMask <<= 1;
|
||||
}
|
||||
|
||||
/* Return the retrieved bit from the buffer */
|
||||
return Bit;
|
||||
}
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** Circular bit buffer library. This will allow for individual bits
|
||||
* to be stored in packed form inside circular buffers, to reduce
|
||||
* overall RAM usage.
|
||||
*/
|
||||
|
||||
#include "CircularBitBuffer.h"
|
||||
|
||||
/** Function to initialize or reset a bit buffer, ready for data to be stored into it. */
|
||||
void BitBuffer_Init(BitBuffer_t* const Buffer)
|
||||
{
|
||||
/* Reset the number of stored bits in the buffer */
|
||||
Buffer->Elements = 0;
|
||||
|
||||
/* Reset the data in and out pointer structures in the buffer to the first buffer bit */
|
||||
Buffer->In.CurrentByte = Buffer->Data;
|
||||
Buffer->In.ByteMask = (1 << 0);
|
||||
Buffer->Out.CurrentByte = Buffer->Data;
|
||||
Buffer->Out.ByteMask = (1 << 0);
|
||||
}
|
||||
|
||||
/** Function to store the given bit into the given bit buffer. */
|
||||
void BitBuffer_StoreNextBit(BitBuffer_t* const Buffer, const bool Bit)
|
||||
{
|
||||
/* If the bit to store is true, set the next bit in the buffer */
|
||||
if (Bit)
|
||||
*Buffer->In.CurrentByte |= Buffer->In.ByteMask;
|
||||
|
||||
/* Increment the number of stored bits in the buffer counter */
|
||||
Buffer->Elements++;
|
||||
|
||||
/* Check if the current buffer byte is full of stored bits */
|
||||
if (Buffer->In.ByteMask == (1 << 7))
|
||||
{
|
||||
/* Check if the end of the buffer has been reached, if so reset to start of buffer, otherwise advance to next bit */
|
||||
if (Buffer->In.CurrentByte != &Buffer->Data[sizeof(Buffer->Data) - 1])
|
||||
Buffer->In.CurrentByte++;
|
||||
else
|
||||
Buffer->In.CurrentByte = Buffer->Data;
|
||||
|
||||
/* Reset the storage bit mask in the current buffer byte to the first bit */
|
||||
Buffer->In.ByteMask = (1 << 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Shift the current storage bit mask to the next bit in the current byte */
|
||||
Buffer->In.ByteMask <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/** Function to retrieve the next bit stored in the given bit buffer. */
|
||||
bool BitBuffer_GetNextBit(BitBuffer_t* const Buffer)
|
||||
{
|
||||
/* Retrieve the value of the next bit stored in the buffer */
|
||||
bool Bit = ((*Buffer->Out.CurrentByte & Buffer->Out.ByteMask) != 0);
|
||||
|
||||
/* Clear the buffer bit */
|
||||
*Buffer->Out.CurrentByte &= ~Buffer->Out.ByteMask;
|
||||
|
||||
/* Decrement the number of stored bits in the buffer counter */
|
||||
Buffer->Elements--;
|
||||
|
||||
/* Check if the current buffer byte is empty of stored bits */
|
||||
if (Buffer->Out.ByteMask == (1 << 7))
|
||||
{
|
||||
/* Check if the end of the buffer has been reached, if so reset to start of buffer, otherwise advance to next bit */
|
||||
if (Buffer->Out.CurrentByte != &Buffer->Data[sizeof(Buffer->Data) - 1])
|
||||
Buffer->Out.CurrentByte++;
|
||||
else
|
||||
Buffer->Out.CurrentByte = Buffer->Data;
|
||||
|
||||
/* Reset the retrieval bit mask in the current buffer byte to the first bit */
|
||||
Buffer->Out.ByteMask = (1 << 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Shift the current retrieval bit mask to the next bit in the current byte */
|
||||
Buffer->Out.ByteMask <<= 1;
|
||||
}
|
||||
|
||||
/* Return the retrieved bit from the buffer */
|
||||
return Bit;
|
||||
}
|
||||
|
|
|
@ -1,95 +1,95 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for CircularBitBuffer.c.
|
||||
*/
|
||||
|
||||
#ifndef _CIRCULARBITBUFFER_H_
|
||||
#define _CIRCULARBITBUFFER_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
/* Macros: */
|
||||
#if (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
|
||||
defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__)) || defined(__DOXYGEN__)
|
||||
/** Maximum number of bits which can be stored into a bit buffer. The memory usage is one eighth of this value per buffer. */
|
||||
#define MAX_BITS 8192
|
||||
#else
|
||||
#define MAX_BITS 1024
|
||||
#endif
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for a pointer to a bit in a bit buffer. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t* CurrentByte; /**< Pointer to the current byte in the buffer */
|
||||
uint8_t ByteMask; /**< Mask of the current bit in the buffer */
|
||||
} BitBufferPointer_t;
|
||||
|
||||
/** Type define for a circular packet bit buffer. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Data[MAX_BITS / 8]; /**< Buffer to hold the stored bits in packed form */
|
||||
uint16_t Elements; /**< Number of stored bits in the bit buffer */
|
||||
|
||||
BitBufferPointer_t In; /**< Bit pointer to the next storage location in the buffer */
|
||||
BitBufferPointer_t Out; /**< Bit pointer to the next retrieval location in the buffer */
|
||||
} BitBuffer_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
/** Initializes or resets a given bit buffer, ready to store new bits.
|
||||
*
|
||||
* \param[in,out] Buffer Bit buffer to initialize
|
||||
*/
|
||||
void BitBuffer_Init(BitBuffer_t* const Buffer) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
||||
/** Stores a bit into the next location inside a given bit buffer.
|
||||
*
|
||||
* \param[in,out] Buffer Bit buffer to store a bit into
|
||||
* \param[in] Bit Bit to store into the buffer
|
||||
*/
|
||||
void BitBuffer_StoreNextBit(BitBuffer_t* const Buffer, const bool Bit) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
||||
/** Retrieves a bit from the next location inside a given bit buffer.
|
||||
*
|
||||
* \param[in,out] Buffer Bit buffer to store a bit into
|
||||
*
|
||||
* \return Next bit from the buffer
|
||||
*/
|
||||
bool BitBuffer_GetNextBit(BitBuffer_t* const Buffer) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
||||
#endif
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for CircularBitBuffer.c.
|
||||
*/
|
||||
|
||||
#ifndef _CIRCULARBITBUFFER_H_
|
||||
#define _CIRCULARBITBUFFER_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
/* Macros: */
|
||||
#if (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
|
||||
defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__)) || defined(__DOXYGEN__)
|
||||
/** Maximum number of bits which can be stored into a bit buffer. The memory usage is one eighth of this value per buffer. */
|
||||
#define MAX_BITS 8192
|
||||
#else
|
||||
#define MAX_BITS 1024
|
||||
#endif
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for a pointer to a bit in a bit buffer. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t* CurrentByte; /**< Pointer to the current byte in the buffer */
|
||||
uint8_t ByteMask; /**< Mask of the current bit in the buffer */
|
||||
} BitBufferPointer_t;
|
||||
|
||||
/** Type define for a circular packet bit buffer. */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Data[MAX_BITS / 8]; /**< Buffer to hold the stored bits in packed form */
|
||||
uint16_t Elements; /**< Number of stored bits in the bit buffer */
|
||||
|
||||
BitBufferPointer_t In; /**< Bit pointer to the next storage location in the buffer */
|
||||
BitBufferPointer_t Out; /**< Bit pointer to the next retrieval location in the buffer */
|
||||
} BitBuffer_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
/** Initializes or resets a given bit buffer, ready to store new bits.
|
||||
*
|
||||
* \param[in,out] Buffer Bit buffer to initialize
|
||||
*/
|
||||
void BitBuffer_Init(BitBuffer_t* const Buffer) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
||||
/** Stores a bit into the next location inside a given bit buffer.
|
||||
*
|
||||
* \param[in,out] Buffer Bit buffer to store a bit into
|
||||
* \param[in] Bit Bit to store into the buffer
|
||||
*/
|
||||
void BitBuffer_StoreNextBit(BitBuffer_t* const Buffer, const bool Bit) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
||||
/** Retrieves a bit from the next location inside a given bit buffer.
|
||||
*
|
||||
* \param[in,out] Buffer Bit buffer to store a bit into
|
||||
*
|
||||
* \return Next bit from the buffer
|
||||
*/
|
||||
bool BitBuffer_GetNextBit(BitBuffer_t* const Buffer) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,100 +1,100 @@
|
|||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/*
|
||||
NOTE: The user of this include file MUST define the following macros
|
||||
prior to including the file:
|
||||
|
||||
MAG_T1_CLOCK_PIN Pin connected to Track 1 clock wire (i.e.. PORTC1)
|
||||
MAG_T1_DATA_PIN Pin connected to Track 1 data wire (i.e.. PORTC2)
|
||||
MAG_T2_CLOCK_PIN Pin connected to Track 2 clock wire (i.e.. PORTC3)
|
||||
MAG_T2_DATA_PIN Pin connected to Track 2 data wire (i.e.. PORTC0)
|
||||
MAG_T3_CLOCK_PIN Pin connected to Track 3 clock wire (i.e.. PORTC5)
|
||||
MAG_T3_DATA_PIN Pin connected to Track 3 data wire (i.e.. PORTC6)
|
||||
MAG_CLS_PIN Pin connected to card loaded wire (i.e.. PORTC4)
|
||||
MAG_PIN PIN macro for the reader's port (i.e.. PINC)
|
||||
MAG_DDR DDR macro for the reader's port (i.e.. DDRC)
|
||||
MAG_PORT PORT macro for the reader's port (i.e.. PORTC)
|
||||
|
||||
The example macros listed above assume that the Track 2 data wire is
|
||||
connected to pin 0 on port C, the Track 2 clock wire is connected to
|
||||
pin 3 on port C (similarly for Tracks 1 and 3), and the card loaded
|
||||
wire is connected to pin 4 on port C.
|
||||
|
||||
If the mag-stripe reader you are using only reads one or two tracks,
|
||||
then set the clock and data pins for the tracks it doesn't read to a
|
||||
pin that is unused. For example, on the AT90USBKey, any of the pins on
|
||||
port C that do not have wires attached will be unused since they are
|
||||
not connected to any onboard devices (such as the joystick or
|
||||
temperature sensor).
|
||||
|
||||
Connecting wires to pins on different ports (i.e.. a data wire to pin 0
|
||||
on port C and a clock wire to pin 0 on port D) is currently
|
||||
unsupported. All pins specified above must be on the same port.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Driver header for a TTL Magnetic Card reader device (such as the Omron V3B-4K).
|
||||
*/
|
||||
|
||||
#ifndef _MAGSTRIPEHW_H_
|
||||
#define _MAGSTRIPEHW_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
/* Macros: */
|
||||
/** Mask of the track data, clock and card detection pins. */
|
||||
#define MAG_MASK (MAG_T1_DATA | MAG_T1_CLOCK | \
|
||||
MAG_T2_DATA | MAG_T2_CLOCK | \
|
||||
MAG_T3_DATA | MAG_T3_CLOCK | \
|
||||
MAG_CARDPRESENT)
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Inline Functions: */
|
||||
/** Initializes the magnetic stripe card reader ports and pins so that the card reader
|
||||
* device can be controlled and read by the card reader driver. This must be called before
|
||||
* trying to read any of the card reader's status lines.
|
||||
*/
|
||||
static inline void Magstripe_Init(void)
|
||||
{
|
||||
MAG_DDR &= ~MAG_MASK;
|
||||
MAG_PORT |= MAG_MASK;
|
||||
};
|
||||
|
||||
/** Returns the status of all the magnetic card reader's outputs.
|
||||
*
|
||||
* \return A mask indicating which card lines are high or low
|
||||
*/
|
||||
static inline uint8_t Magstripe_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t Magstripe_GetStatus(void)
|
||||
{
|
||||
/* Mag-stripe IOs are active low and must be inverted when read */
|
||||
return ((uint8_t)~MAG_PIN & MAG_MASK);
|
||||
}
|
||||
|
||||
#endif
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/*
|
||||
NOTE: The user of this include file MUST define the following macros
|
||||
prior to including the file:
|
||||
|
||||
MAG_T1_CLOCK_PIN Pin connected to Track 1 clock wire (i.e.. PORTC1)
|
||||
MAG_T1_DATA_PIN Pin connected to Track 1 data wire (i.e.. PORTC2)
|
||||
MAG_T2_CLOCK_PIN Pin connected to Track 2 clock wire (i.e.. PORTC3)
|
||||
MAG_T2_DATA_PIN Pin connected to Track 2 data wire (i.e.. PORTC0)
|
||||
MAG_T3_CLOCK_PIN Pin connected to Track 3 clock wire (i.e.. PORTC5)
|
||||
MAG_T3_DATA_PIN Pin connected to Track 3 data wire (i.e.. PORTC6)
|
||||
MAG_CLS_PIN Pin connected to card loaded wire (i.e.. PORTC4)
|
||||
MAG_PIN PIN macro for the reader's port (i.e.. PINC)
|
||||
MAG_DDR DDR macro for the reader's port (i.e.. DDRC)
|
||||
MAG_PORT PORT macro for the reader's port (i.e.. PORTC)
|
||||
|
||||
The example macros listed above assume that the Track 2 data wire is
|
||||
connected to pin 0 on port C, the Track 2 clock wire is connected to
|
||||
pin 3 on port C (similarly for Tracks 1 and 3), and the card loaded
|
||||
wire is connected to pin 4 on port C.
|
||||
|
||||
If the mag-stripe reader you are using only reads one or two tracks,
|
||||
then set the clock and data pins for the tracks it doesn't read to a
|
||||
pin that is unused. For example, on the AT90USBKey, any of the pins on
|
||||
port C that do not have wires attached will be unused since they are
|
||||
not connected to any onboard devices (such as the joystick or
|
||||
temperature sensor).
|
||||
|
||||
Connecting wires to pins on different ports (i.e.. a data wire to pin 0
|
||||
on port C and a clock wire to pin 0 on port D) is currently
|
||||
unsupported. All pins specified above must be on the same port.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Driver header for a TTL Magnetic Card reader device (such as the Omron V3B-4K).
|
||||
*/
|
||||
|
||||
#ifndef _MAGSTRIPEHW_H_
|
||||
#define _MAGSTRIPEHW_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
/* Macros: */
|
||||
/** Mask of the track data, clock and card detection pins. */
|
||||
#define MAG_MASK (MAG_T1_DATA | MAG_T1_CLOCK | \
|
||||
MAG_T2_DATA | MAG_T2_CLOCK | \
|
||||
MAG_T3_DATA | MAG_T3_CLOCK | \
|
||||
MAG_CARDPRESENT)
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Inline Functions: */
|
||||
/** Initializes the magnetic stripe card reader ports and pins so that the card reader
|
||||
* device can be controlled and read by the card reader driver. This must be called before
|
||||
* trying to read any of the card reader's status lines.
|
||||
*/
|
||||
static inline void Magstripe_Init(void)
|
||||
{
|
||||
MAG_DDR &= ~MAG_MASK;
|
||||
MAG_PORT |= MAG_MASK;
|
||||
};
|
||||
|
||||
/** Returns the status of all the magnetic card reader's outputs.
|
||||
*
|
||||
* \return A mask indicating which card lines are high or low
|
||||
*/
|
||||
static inline uint8_t Magstripe_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t Magstripe_GetStatus(void)
|
||||
{
|
||||
/* Mag-stripe IOs are active low and must be inverted when read */
|
||||
return ((uint8_t)~MAG_PIN & MAG_MASK);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,216 +1,216 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Main source file for the MagStripe reader program. This file contains the main tasks of
|
||||
* the project and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
#include "Magstripe.h"
|
||||
|
||||
/** Bit buffers to hold the read bits for each of the three magnetic card tracks before they are transmitted
|
||||
* to the host as keyboard presses.
|
||||
*/
|
||||
BitBuffer_t TrackDataBuffers[TOTAL_TRACKS];
|
||||
|
||||
/** Pointer to the current track buffer being sent to the host. */
|
||||
BitBuffer_t* CurrentTrackBuffer = &TrackDataBuffers[TOTAL_TRACKS];
|
||||
|
||||
/** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */
|
||||
uint8_t PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)];
|
||||
|
||||
/** LUFA HID Class driver interface configuration and state information. This structure is
|
||||
* passed to all HID Class driver functions, so that multiple instances of the same class
|
||||
* within a device can be differentiated from one another.
|
||||
*/
|
||||
USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.InterfaceNumber = 0,
|
||||
|
||||
.ReportINEndpointNumber = KEYBOARD_EPNUM,
|
||||
.ReportINEndpointSize = KEYBOARD_EPSIZE,
|
||||
.ReportINEndpointDoubleBank = KEYBOARD_EPSIZE,
|
||||
|
||||
.PrevReportINBuffer = PrevKeyboardHIDReportBuffer,
|
||||
.PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),
|
||||
},
|
||||
};
|
||||
|
||||
/** Main program entry point. This routine contains the overall program flow, including initial
|
||||
* setup of all components and the main program loop.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
for (uint8_t Buffer = 0; Buffer < TOTAL_TRACKS; Buffer++)
|
||||
BitBuffer_Init(&TrackDataBuffers[Buffer]);
|
||||
|
||||
sei();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (Magstripe_GetStatus() & MAG_CARDPRESENT)
|
||||
ReadMagstripeData();
|
||||
|
||||
HID_Device_USBTask(&Keyboard_HID_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
/* Hardware Initialization */
|
||||
Magstripe_Init();
|
||||
USB_Init();
|
||||
}
|
||||
|
||||
/** Determines if a card has been inserted, and if so reads in each track's contents into the bit buffers
|
||||
* until they are read out to the host as a series of keyboard presses.
|
||||
*/
|
||||
void ReadMagstripeData(void)
|
||||
{
|
||||
/* Arrays to hold the buffer pointers, clock and data bit masks for the separate card tracks */
|
||||
const struct
|
||||
{
|
||||
uint8_t ClockMask;
|
||||
uint8_t DataMask;
|
||||
} TrackInfo[] = {{MAG_T1_CLOCK, MAG_T1_DATA},
|
||||
{MAG_T2_CLOCK, MAG_T2_DATA},
|
||||
{MAG_T3_CLOCK, MAG_T3_DATA}};
|
||||
|
||||
uint8_t Magstripe_Prev = 0;
|
||||
uint8_t Magstripe_LCL = Magstripe_GetStatus();
|
||||
|
||||
while (Magstripe_LCL & MAG_CARDPRESENT)
|
||||
{
|
||||
for (uint8_t Track = 0; Track < TOTAL_TRACKS; Track++)
|
||||
{
|
||||
bool DataPinLevel = ((Magstripe_LCL & TrackInfo[Track].DataMask) != 0);
|
||||
bool ClockPinLevel = ((Magstripe_LCL & TrackInfo[Track].ClockMask) != 0);
|
||||
bool ClockLevelChanged = (((Magstripe_LCL ^ Magstripe_Prev) & TrackInfo[Track].ClockMask) != 0);
|
||||
|
||||
/* Sample data on rising clock edges from the card reader */
|
||||
if (ClockPinLevel && ClockLevelChanged)
|
||||
BitBuffer_StoreNextBit(&TrackDataBuffers[Track], DataPinLevel);
|
||||
}
|
||||
|
||||
Magstripe_Prev = Magstripe_LCL;
|
||||
Magstripe_LCL = Magstripe_GetStatus();
|
||||
}
|
||||
|
||||
CurrentTrackBuffer = &TrackDataBuffers[0];
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Configuration Changed event. */
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
HID_Device_ConfigureEndpoints(&Keyboard_HID_Interface);
|
||||
|
||||
USB_Device_EnableSOFEvents();
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Unhandled Control Packet event. */
|
||||
void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||
{
|
||||
HID_Device_ProcessControlRequest(&Keyboard_HID_Interface);
|
||||
}
|
||||
|
||||
/** Event handler for the USB device Start Of Frame event. */
|
||||
void EVENT_USB_Device_StartOfFrame(void)
|
||||
{
|
||||
HID_Device_MillisecondElapsed(&Keyboard_HID_Interface);
|
||||
}
|
||||
|
||||
/** HID class driver callback function for the creation of HID reports to the host.
|
||||
*
|
||||
* \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced
|
||||
* \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID
|
||||
* \param[in] ReportType Type of the report to create, either REPORT_ITEM_TYPE_In or REPORT_ITEM_TYPE_Feature
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent
|
||||
*
|
||||
* \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,
|
||||
const uint8_t ReportType, void* ReportData, uint16_t* ReportSize)
|
||||
{
|
||||
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
|
||||
|
||||
static bool IsKeyReleaseReport;
|
||||
|
||||
/* Key reports must be interleaved with key release reports, or repeated keys will be ignored */
|
||||
IsKeyReleaseReport = !IsKeyReleaseReport;
|
||||
|
||||
if ((IsKeyReleaseReport) || (CurrentTrackBuffer == &TrackDataBuffers[TOTAL_TRACKS]))
|
||||
{
|
||||
/* No more data to send, or key release report between key presses */
|
||||
KeyboardReport->KeyCode[0] = KEY_NONE;
|
||||
}
|
||||
else if (!(CurrentTrackBuffer->Elements))
|
||||
{
|
||||
/* End of current track, send an enter press and change to the next track's buffer */
|
||||
KeyboardReport->KeyCode[0] = KEY_ENTER;
|
||||
CurrentTrackBuffer++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Still data in the current track; convert next bit to a 1 or 0 keypress */
|
||||
KeyboardReport->KeyCode[0] = BitBuffer_GetNextBit(CurrentTrackBuffer) ? KEY_1 : KEY_0;
|
||||
}
|
||||
|
||||
*ReportSize = sizeof(USB_KeyboardReport_Data_t);
|
||||
return false;
|
||||
}
|
||||
|
||||
/** HID Class driver callback function for the processing of a received HID report from the host.
|
||||
*
|
||||
* \param[in] HIDInterfaceInfo Pointer to the HID interface structure for the HID interface being referenced
|
||||
* \param[in] ReportID Report ID of the received report from the host
|
||||
* \param[in] ReportData Pointer to the report buffer where the received report is stored
|
||||
* \param[in] ReportSize Size in bytes of the report received from the host
|
||||
*/
|
||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID,
|
||||
const void* ReportData, const uint16_t ReportSize)
|
||||
{
|
||||
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
|
||||
}
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Main source file for the MagStripe reader program. This file contains the main tasks of
|
||||
* the project and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
#include "Magstripe.h"
|
||||
|
||||
/** Bit buffers to hold the read bits for each of the three magnetic card tracks before they are transmitted
|
||||
* to the host as keyboard presses.
|
||||
*/
|
||||
BitBuffer_t TrackDataBuffers[TOTAL_TRACKS];
|
||||
|
||||
/** Pointer to the current track buffer being sent to the host. */
|
||||
BitBuffer_t* CurrentTrackBuffer = &TrackDataBuffers[TOTAL_TRACKS];
|
||||
|
||||
/** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */
|
||||
uint8_t PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)];
|
||||
|
||||
/** LUFA HID Class driver interface configuration and state information. This structure is
|
||||
* passed to all HID Class driver functions, so that multiple instances of the same class
|
||||
* within a device can be differentiated from one another.
|
||||
*/
|
||||
USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
|
||||
{
|
||||
.Config =
|
||||
{
|
||||
.InterfaceNumber = 0,
|
||||
|
||||
.ReportINEndpointNumber = KEYBOARD_EPNUM,
|
||||
.ReportINEndpointSize = KEYBOARD_EPSIZE,
|
||||
.ReportINEndpointDoubleBank = KEYBOARD_EPSIZE,
|
||||
|
||||
.PrevReportINBuffer = PrevKeyboardHIDReportBuffer,
|
||||
.PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),
|
||||
},
|
||||
};
|
||||
|
||||
/** Main program entry point. This routine contains the overall program flow, including initial
|
||||
* setup of all components and the main program loop.
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
for (uint8_t Buffer = 0; Buffer < TOTAL_TRACKS; Buffer++)
|
||||
BitBuffer_Init(&TrackDataBuffers[Buffer]);
|
||||
|
||||
sei();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (Magstripe_GetStatus() & MAG_CARDPRESENT)
|
||||
ReadMagstripeData();
|
||||
|
||||
HID_Device_USBTask(&Keyboard_HID_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures the board hardware and chip peripherals for the demo's functionality. */
|
||||
void SetupHardware(void)
|
||||
{
|
||||
/* Disable watchdog if enabled by bootloader/fuses */
|
||||
MCUSR &= ~(1 << WDRF);
|
||||
wdt_disable();
|
||||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
/* Hardware Initialization */
|
||||
Magstripe_Init();
|
||||
USB_Init();
|
||||
}
|
||||
|
||||
/** Determines if a card has been inserted, and if so reads in each track's contents into the bit buffers
|
||||
* until they are read out to the host as a series of keyboard presses.
|
||||
*/
|
||||
void ReadMagstripeData(void)
|
||||
{
|
||||
/* Arrays to hold the buffer pointers, clock and data bit masks for the separate card tracks */
|
||||
const struct
|
||||
{
|
||||
uint8_t ClockMask;
|
||||
uint8_t DataMask;
|
||||
} TrackInfo[] = {{MAG_T1_CLOCK, MAG_T1_DATA},
|
||||
{MAG_T2_CLOCK, MAG_T2_DATA},
|
||||
{MAG_T3_CLOCK, MAG_T3_DATA}};
|
||||
|
||||
uint8_t Magstripe_Prev = 0;
|
||||
uint8_t Magstripe_LCL = Magstripe_GetStatus();
|
||||
|
||||
while (Magstripe_LCL & MAG_CARDPRESENT)
|
||||
{
|
||||
for (uint8_t Track = 0; Track < TOTAL_TRACKS; Track++)
|
||||
{
|
||||
bool DataPinLevel = ((Magstripe_LCL & TrackInfo[Track].DataMask) != 0);
|
||||
bool ClockPinLevel = ((Magstripe_LCL & TrackInfo[Track].ClockMask) != 0);
|
||||
bool ClockLevelChanged = (((Magstripe_LCL ^ Magstripe_Prev) & TrackInfo[Track].ClockMask) != 0);
|
||||
|
||||
/* Sample data on rising clock edges from the card reader */
|
||||
if (ClockPinLevel && ClockLevelChanged)
|
||||
BitBuffer_StoreNextBit(&TrackDataBuffers[Track], DataPinLevel);
|
||||
}
|
||||
|
||||
Magstripe_Prev = Magstripe_LCL;
|
||||
Magstripe_LCL = Magstripe_GetStatus();
|
||||
}
|
||||
|
||||
CurrentTrackBuffer = &TrackDataBuffers[0];
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Configuration Changed event. */
|
||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||
{
|
||||
HID_Device_ConfigureEndpoints(&Keyboard_HID_Interface);
|
||||
|
||||
USB_Device_EnableSOFEvents();
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Unhandled Control Packet event. */
|
||||
void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||
{
|
||||
HID_Device_ProcessControlRequest(&Keyboard_HID_Interface);
|
||||
}
|
||||
|
||||
/** Event handler for the USB device Start Of Frame event. */
|
||||
void EVENT_USB_Device_StartOfFrame(void)
|
||||
{
|
||||
HID_Device_MillisecondElapsed(&Keyboard_HID_Interface);
|
||||
}
|
||||
|
||||
/** HID class driver callback function for the creation of HID reports to the host.
|
||||
*
|
||||
* \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced
|
||||
* \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID
|
||||
* \param[in] ReportType Type of the report to create, either REPORT_ITEM_TYPE_In or REPORT_ITEM_TYPE_Feature
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
* \param[out] ReportSize Number of bytes written in the report (or zero if no report is to be sent
|
||||
*
|
||||
* \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
|
||||
*/
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,
|
||||
const uint8_t ReportType, void* ReportData, uint16_t* ReportSize)
|
||||
{
|
||||
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
|
||||
|
||||
static bool IsKeyReleaseReport;
|
||||
|
||||
/* Key reports must be interleaved with key release reports, or repeated keys will be ignored */
|
||||
IsKeyReleaseReport = !IsKeyReleaseReport;
|
||||
|
||||
if ((IsKeyReleaseReport) || (CurrentTrackBuffer == &TrackDataBuffers[TOTAL_TRACKS]))
|
||||
{
|
||||
/* No more data to send, or key release report between key presses */
|
||||
KeyboardReport->KeyCode[0] = KEY_NONE;
|
||||
}
|
||||
else if (!(CurrentTrackBuffer->Elements))
|
||||
{
|
||||
/* End of current track, send an enter press and change to the next track's buffer */
|
||||
KeyboardReport->KeyCode[0] = KEY_ENTER;
|
||||
CurrentTrackBuffer++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Still data in the current track; convert next bit to a 1 or 0 keypress */
|
||||
KeyboardReport->KeyCode[0] = BitBuffer_GetNextBit(CurrentTrackBuffer) ? KEY_1 : KEY_0;
|
||||
}
|
||||
|
||||
*ReportSize = sizeof(USB_KeyboardReport_Data_t);
|
||||
return false;
|
||||
}
|
||||
|
||||
/** HID Class driver callback function for the processing of a received HID report from the host.
|
||||
*
|
||||
* \param[in] HIDInterfaceInfo Pointer to the HID interface structure for the HID interface being referenced
|
||||
* \param[in] ReportID Report ID of the received report from the host
|
||||
* \param[in] ReportData Pointer to the report buffer where the received report is stored
|
||||
* \param[in] ReportSize Size in bytes of the report received from the host
|
||||
*/
|
||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID,
|
||||
const void* ReportData, const uint16_t ReportSize)
|
||||
{
|
||||
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
|
||||
}
|
||||
|
|
|
@ -1,83 +1,83 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for Magstripe.c.
|
||||
*/
|
||||
|
||||
#ifndef _MAGSTRIPE_H_
|
||||
#define _MAGSTRIPE_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
#include "Lib/MagstripeHW.h"
|
||||
#include "Lib/CircularBitBuffer.h"
|
||||
|
||||
#include <LUFA/Version.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Total number of tracks which can be read from the card, between 1 and 3. */
|
||||
#define TOTAL_TRACKS 3
|
||||
|
||||
/** 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
|
||||
|
||||
/** HID keyboard keycode to indicate that the "0" key is currently pressed. */
|
||||
#define KEY_0 39
|
||||
|
||||
/** HID keyboard keycode to indicate that the enter key is currently pressed. */
|
||||
#define KEY_ENTER 40
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
void ReadMagstripeData(void);
|
||||
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||
void EVENT_USB_Device_StartOfFrame(void);
|
||||
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,
|
||||
const uint8_t ReportType, void* ReportData, uint16_t* ReportSize);
|
||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID,
|
||||
const void* ReportData, const uint16_t ReportSize);
|
||||
|
||||
#endif
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2010 Denver Gingerich (denver [at] ossguy [dot] com)
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
software, including all implied warranties of merchantability
|
||||
and fitness. In no event shall the author be liable for any
|
||||
special, indirect or consequential damages or any damages
|
||||
whatsoever resulting from loss of use, data or profits, whether
|
||||
in an action of contract, negligence or other tortious action,
|
||||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Header file for Magstripe.c.
|
||||
*/
|
||||
|
||||
#ifndef _MAGSTRIPE_H_
|
||||
#define _MAGSTRIPE_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "Descriptors.h"
|
||||
#include "Lib/MagstripeHW.h"
|
||||
#include "Lib/CircularBitBuffer.h"
|
||||
|
||||
#include <LUFA/Version.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||
|
||||
/* Macros: */
|
||||
/** Total number of tracks which can be read from the card, between 1 and 3. */
|
||||
#define TOTAL_TRACKS 3
|
||||
|
||||
/** 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
|
||||
|
||||
/** HID keyboard keycode to indicate that the "0" key is currently pressed. */
|
||||
#define KEY_0 39
|
||||
|
||||
/** HID keyboard keycode to indicate that the enter key is currently pressed. */
|
||||
#define KEY_ENTER 40
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
void ReadMagstripeData(void);
|
||||
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||
void EVENT_USB_Device_StartOfFrame(void);
|
||||
|
||||
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, uint8_t* const ReportID,
|
||||
const uint8_t ReportType, void* ReportData, uint16_t* ReportSize);
|
||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, const uint8_t ReportID,
|
||||
const void* ReportData, const uint16_t ReportSize);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,164 +1,164 @@
|
|||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage Denver Gingerich's USBSnoop Magnetic Card Reader Project
|
||||
*
|
||||
* \section SSec_Compat Project Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this project.
|
||||
*
|
||||
* - AT90USB1287
|
||||
* - AT90USB1286
|
||||
*
|
||||
* \section SSec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this project.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Keyboard</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF HID Standard, USBIF HID Usage Tables</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Usable Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Firmware for a USB AVR powered USB TTL magnetic stripe reader (using a card
|
||||
* reader such as the Omron V3B-4K) by Denver Gingerich. This project is designed
|
||||
* to be used with the open source Stripe Snoop project at <a>http://stripesnoop.sourceforge.net/</a>.
|
||||
*
|
||||
* See <a>http://ossguy.com/ss_usb/</a> for the USB reader hardware project website,
|
||||
* including construction and support details.
|
||||
*
|
||||
* To use, connect your magnetic card reader device to the USB AVR as follows (pin and port mapping may be adjusted
|
||||
* from the project makefile):
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>Signal:</b></td>
|
||||
* <td><b>AVR Port:</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 1 Data</td>
|
||||
* <td>PORTC, Pin 1</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 1 Clock</td>
|
||||
* <td>PORTC, Pin 2</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 2 Data</td>
|
||||
* <td>PORTC, Pin 3</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 2 Clock</td>
|
||||
* <td>PORTC, Pin 0</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 3 Data</td>
|
||||
* <td>PORTC, Pin 5</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 3 Clock</td>
|
||||
* <td>PORTC, Pin 6</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Card Detect</td>
|
||||
* <td>PORTC, Pin 4</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* This project is based on the LUFA Keyboard projectnstration application,
|
||||
* written by Denver Gingerich.
|
||||
*
|
||||
* This application uses a keyboard HID driver to communicate the data collected
|
||||
* a TTL magnetic stripe reader to the connected computer. The raw bitstream
|
||||
* obtained from the magnetic stripe reader is "typed" through the keyboard
|
||||
* driver as 0's and 1's. After every card swipe, the project will send a return key.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this project, which can control the project behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>Define Name:</b></td>
|
||||
* <td><b>Location:</b></td>
|
||||
* <td><b>Description:</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAX_BITS</td>
|
||||
* <td>CircularBitBuffer.h</td>
|
||||
* <td>Gives the maximum number of bits per track which can be buffered by the device for later transmission to a host.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T1_CLOCK</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's CLOCK line for the reader's track 1 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T1_DATA</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's DATA line for the reader's track 1 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T2_CLOCK</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's CLOCK line for the reader's track 2 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T2_DATA</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's DATA line for the reader's track 2 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T3_CLOCK</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's CLOCK line for the reader's track 3 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T3_DATA</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's DATA line for the reader's track 3 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_CARDPRESENT</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's card detection output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_PIN</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>PIN register that the magnetic card reader device is attached to.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_PORT</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>PORT register that the magnetic card reader device is attached to.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_DDR</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>DDR register that the magnetic card reader device is attached to.</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
/** \file
|
||||
*
|
||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
/** \mainpage Denver Gingerich's USBSnoop Magnetic Card Reader Project
|
||||
*
|
||||
* \section SSec_Compat Project Compatibility:
|
||||
*
|
||||
* The following list indicates what microcontrollers are compatible with this project.
|
||||
*
|
||||
* - AT90USB1287
|
||||
* - AT90USB1286
|
||||
*
|
||||
* \section SSec_Info USB Information:
|
||||
*
|
||||
* The following table gives a rundown of the USB utilization of this project.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>USB Mode:</b></td>
|
||||
* <td>Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Keyboard</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Relevant Standards:</b></td>
|
||||
* <td>USBIF HID Standard, USBIF HID Usage Tables</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td><b>Usable Speeds:</b></td>
|
||||
* <td>Full Speed Mode</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Firmware for a USB AVR powered USB TTL magnetic stripe reader (using a card
|
||||
* reader such as the Omron V3B-4K) by Denver Gingerich. This project is designed
|
||||
* to be used with the open source Stripe Snoop project at <a>http://stripesnoop.sourceforge.net/</a>.
|
||||
*
|
||||
* See <a>http://ossguy.com/ss_usb/</a> for the USB reader hardware project website,
|
||||
* including construction and support details.
|
||||
*
|
||||
* To use, connect your magnetic card reader device to the USB AVR as follows (pin and port mapping may be adjusted
|
||||
* from the project makefile):
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>Signal:</b></td>
|
||||
* <td><b>AVR Port:</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 1 Data</td>
|
||||
* <td>PORTC, Pin 1</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 1 Clock</td>
|
||||
* <td>PORTC, Pin 2</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 2 Data</td>
|
||||
* <td>PORTC, Pin 3</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 2 Clock</td>
|
||||
* <td>PORTC, Pin 0</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 3 Data</td>
|
||||
* <td>PORTC, Pin 5</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Track 3 Clock</td>
|
||||
* <td>PORTC, Pin 6</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>Card Detect</td>
|
||||
* <td>PORTC, Pin 4</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* This project is based on the LUFA Keyboard projectnstration application,
|
||||
* written by Denver Gingerich.
|
||||
*
|
||||
* This application uses a keyboard HID driver to communicate the data collected
|
||||
* a TTL magnetic stripe reader to the connected computer. The raw bitstream
|
||||
* obtained from the magnetic stripe reader is "typed" through the keyboard
|
||||
* driver as 0's and 1's. After every card swipe, the project will send a return key.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this project, which can control the project behaviour when defined, or changed in value.
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>Define Name:</b></td>
|
||||
* <td><b>Location:</b></td>
|
||||
* <td><b>Description:</b></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAX_BITS</td>
|
||||
* <td>CircularBitBuffer.h</td>
|
||||
* <td>Gives the maximum number of bits per track which can be buffered by the device for later transmission to a host.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T1_CLOCK</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's CLOCK line for the reader's track 1 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T1_DATA</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's DATA line for the reader's track 1 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T2_CLOCK</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's CLOCK line for the reader's track 2 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T2_DATA</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's DATA line for the reader's track 2 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T3_CLOCK</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's CLOCK line for the reader's track 3 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_T3_DATA</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's DATA line for the reader's track 3 output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_CARDPRESENT</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>Mask for the magnetic card reader's card detection output.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_PIN</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>PIN register that the magnetic card reader device is attached to.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_PORT</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>PORT register that the magnetic card reader device is attached to.</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>MAG_DDR</td>
|
||||
* <td>Makefile CDEFS</td>
|
||||
* <td>DDR register that the magnetic card reader device is attached to.</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue