From b7ef7f49c9f6b4de962ae32776866bd1d5d59c3b Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 22 May 2009 06:17:57 +0000 Subject: Moved out each demos' functionality library files (e.g. Ring Buffer library) to /Lib directories for a better directory structure. --- Projects/Magstripe/CircularBitBuffer.c | 113 ----------------------------- Projects/Magstripe/CircularBitBuffer.h | 95 ------------------------ Projects/Magstripe/Lib/CircularBitBuffer.c | 113 +++++++++++++++++++++++++++++ Projects/Magstripe/Lib/CircularBitBuffer.h | 95 ++++++++++++++++++++++++ Projects/Magstripe/Lib/MagstripeHW.h | 100 +++++++++++++++++++++++++ Projects/Magstripe/Magstripe.h | 5 +- Projects/Magstripe/MagstripeHW.h | 100 ------------------------- Projects/Magstripe/makefile | 2 +- 8 files changed, 312 insertions(+), 311 deletions(-) delete mode 100644 Projects/Magstripe/CircularBitBuffer.c delete mode 100644 Projects/Magstripe/CircularBitBuffer.h create mode 100644 Projects/Magstripe/Lib/CircularBitBuffer.c create mode 100644 Projects/Magstripe/Lib/CircularBitBuffer.h create mode 100644 Projects/Magstripe/Lib/MagstripeHW.h delete mode 100644 Projects/Magstripe/MagstripeHW.h (limited to 'Projects') diff --git a/Projects/Magstripe/CircularBitBuffer.c b/Projects/Magstripe/CircularBitBuffer.c deleted file mode 100644 index 5d23762ec..000000000 --- a/Projects/Magstripe/CircularBitBuffer.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2009. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2009 Denver Gingerich (denver [at] ossguy [dot] com) - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, 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* 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* Buffer, 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* 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; -} diff --git a/Projects/Magstripe/CircularBitBuffer.h b/Projects/Magstripe/CircularBitBuffer.h deleted file mode 100644 index 6f1fa1508..000000000 --- a/Projects/Magstripe/CircularBitBuffer.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2009. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2009 Denver Gingerich (denver [at] ossguy [dot] com) - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, 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 - #include - - #include - - /* 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 Buffer Bit buffer to initialize - */ - void BitBuffer_Init(BitBuffer_t* Buffer) ATTR_NON_NULL_PTR_ARG(1); - - /** Stores a bit into the next location inside a given bit buffer. - * - * \param Buffer Bit buffer to store a bit into - * \param Bit Bit to store into the buffer - */ - void BitBuffer_StoreNextBit(BitBuffer_t* Buffer, bool Bit) ATTR_NON_NULL_PTR_ARG(1); - - /** Retrieves a bit from the next location inside a given bit buffer. - * - * \param Buffer Bit buffer to store a bit into - * - * \return Next bit from the buffer - */ - bool BitBuffer_GetNextBit(BitBuffer_t* Buffer) ATTR_NON_NULL_PTR_ARG(1); - -#endif diff --git a/Projects/Magstripe/Lib/CircularBitBuffer.c b/Projects/Magstripe/Lib/CircularBitBuffer.c new file mode 100644 index 000000000..5d23762ec --- /dev/null +++ b/Projects/Magstripe/Lib/CircularBitBuffer.c @@ -0,0 +1,113 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2009. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2009 Denver Gingerich (denver [at] ossguy [dot] com) + Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, and distribute this software + and its documentation for any purpose and without fee is hereby + granted, 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* 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* Buffer, 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* 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; +} diff --git a/Projects/Magstripe/Lib/CircularBitBuffer.h b/Projects/Magstripe/Lib/CircularBitBuffer.h new file mode 100644 index 000000000..6f1fa1508 --- /dev/null +++ b/Projects/Magstripe/Lib/CircularBitBuffer.h @@ -0,0 +1,95 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2009. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2009 Denver Gingerich (denver [at] ossguy [dot] com) + Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, and distribute this software + and its documentation for any purpose and without fee is hereby + granted, 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 + #include + + #include + + /* 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 Buffer Bit buffer to initialize + */ + void BitBuffer_Init(BitBuffer_t* Buffer) ATTR_NON_NULL_PTR_ARG(1); + + /** Stores a bit into the next location inside a given bit buffer. + * + * \param Buffer Bit buffer to store a bit into + * \param Bit Bit to store into the buffer + */ + void BitBuffer_StoreNextBit(BitBuffer_t* Buffer, bool Bit) ATTR_NON_NULL_PTR_ARG(1); + + /** Retrieves a bit from the next location inside a given bit buffer. + * + * \param Buffer Bit buffer to store a bit into + * + * \return Next bit from the buffer + */ + bool BitBuffer_GetNextBit(BitBuffer_t* Buffer) ATTR_NON_NULL_PTR_ARG(1); + +#endif diff --git a/Projects/Magstripe/Lib/MagstripeHW.h b/Projects/Magstripe/Lib/MagstripeHW.h new file mode 100644 index 000000000..c4681188a --- /dev/null +++ b/Projects/Magstripe/Lib/MagstripeHW.h @@ -0,0 +1,100 @@ +/* + Copyright 2009 Denver Gingerich (denver [at] ossguy [dot] com) + Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, and distribute this software + and its documentation for any purpose and without fee is hereby + granted, 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 (ie. PORTC1) + MAG_T1_DATA_PIN Pin connected to Track 1 data wire (ie. PORTC2) + MAG_T2_CLOCK_PIN Pin connected to Track 2 clock wire (ie. PORTC3) + MAG_T2_DATA_PIN Pin connected to Track 2 data wire (ie. PORTC0) + MAG_T3_CLOCK_PIN Pin connected to Track 3 clock wire (ie. PORTC5) + MAG_T3_DATA_PIN Pin connected to Track 3 data wire (ie. PORTC6) + MAG_CLS_PIN Pin connected to card loaded wire (ie. PORTC4) + MAG_PIN PIN macro for the reader's port (ie. PINC) + MAG_DDR DDR macro for the reader's port (ie. DDRC) + MAG_PORT PORT macro for the reader's port (ie. 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 magstripe 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 (ie. 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 + + #include + + /* 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) + { + /* Magstripe IOs are active low and must be inverted when read */ + return ((uint8_t)~MAG_PIN & MAG_MASK); + } + +#endif diff --git a/Projects/Magstripe/Magstripe.h b/Projects/Magstripe/Magstripe.h index a83496b91..c700bcaff 100644 --- a/Projects/Magstripe/Magstripe.h +++ b/Projects/Magstripe/Magstripe.h @@ -46,8 +46,9 @@ #include #include "Descriptors.h" - #include "MagstripeHW.h" - #include "CircularBitBuffer.h" + + #include "Lib/MagstripeHW.h" + #include "Lib/CircularBitBuffer.h" #include // Library Version Information #include // USB Functionality diff --git a/Projects/Magstripe/MagstripeHW.h b/Projects/Magstripe/MagstripeHW.h deleted file mode 100644 index c4681188a..000000000 --- a/Projects/Magstripe/MagstripeHW.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright 2009 Denver Gingerich (denver [at] ossguy [dot] com) - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, 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 (ie. PORTC1) - MAG_T1_DATA_PIN Pin connected to Track 1 data wire (ie. PORTC2) - MAG_T2_CLOCK_PIN Pin connected to Track 2 clock wire (ie. PORTC3) - MAG_T2_DATA_PIN Pin connected to Track 2 data wire (ie. PORTC0) - MAG_T3_CLOCK_PIN Pin connected to Track 3 clock wire (ie. PORTC5) - MAG_T3_DATA_PIN Pin connected to Track 3 data wire (ie. PORTC6) - MAG_CLS_PIN Pin connected to card loaded wire (ie. PORTC4) - MAG_PIN PIN macro for the reader's port (ie. PINC) - MAG_DDR DDR macro for the reader's port (ie. DDRC) - MAG_PORT PORT macro for the reader's port (ie. 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 magstripe 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 (ie. 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 - - #include - - /* 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) - { - /* Magstripe IOs are active low and must be inverted when read */ - return ((uint8_t)~MAG_PIN & MAG_MASK); - } - -#endif diff --git a/Projects/Magstripe/makefile b/Projects/Magstripe/makefile index 6a77cf05c..962c999b3 100644 --- a/Projects/Magstripe/makefile +++ b/Projects/Magstripe/makefile @@ -125,7 +125,7 @@ LUFA_PATH = ../.. # List C source files here. (C dependencies are automatically generated.) SRC = $(TARGET).c \ Descriptors.c \ - CircularBitBuffer.c \ + Lib/CircularBitBuffer.c \ $(LUFA_PATH)/LUFA/Scheduler/Scheduler.c \ $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \ $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c \ -- cgit v1.2.3