Add tag for the 120219 release.
[pub/USBasp.git] / Projects / Magstripe / Lib / MagstripeHW.h
index 9151448..ef5e908 100644 (file)
-/*\r
-  Copyright 2010  Denver Gingerich (denver [at] ossguy [dot] com)\r
-  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
-  Permission to use, copy, modify, distribute, and sell this \r
-  software and its documentation for any purpose is hereby granted\r
-  without fee, provided that the above copyright notice appear in \r
-  all copies and that both that the copyright notice and this\r
-  permission notice and warranty disclaimer appear in supporting \r
-  documentation, and that the name of the author not be used in \r
-  advertising or publicity pertaining to distribution of the \r
-  software without specific, written prior permission.\r
-\r
-  The author disclaim all warranties with regard to this\r
-  software, including all implied warranties of merchantability\r
-  and fitness.  In no event shall the author be liable for any\r
-  special, indirect or consequential damages or any damages\r
-  whatsoever resulting from loss of use, data or profits, whether\r
-  in an action of contract, negligence or other tortious action,\r
-  arising out of or in connection with the use or performance of\r
-  this software.\r
-*/\r
-\r
-/*\r
-       NOTE: The user of this include file MUST define the following macros\r
-       prior to including the file:\r
-\r
-       MAG_T1_CLOCK_PIN   Pin connected to Track 1 clock wire (i.e.. PORTC1)\r
-       MAG_T1_DATA_PIN    Pin connected to Track 1 data wire (i.e.. PORTC2)\r
-       MAG_T2_CLOCK_PIN   Pin connected to Track 2 clock wire (i.e.. PORTC3)\r
-       MAG_T2_DATA_PIN    Pin connected to Track 2 data wire (i.e.. PORTC0)\r
-       MAG_T3_CLOCK_PIN   Pin connected to Track 3 clock wire (i.e.. PORTC5)\r
-       MAG_T3_DATA_PIN    Pin connected to Track 3 data wire (i.e.. PORTC6)\r
-       MAG_CLS_PIN        Pin connected to card loaded wire (i.e.. PORTC4)\r
-       MAG_PIN            PIN macro for the reader's port (i.e.. PINC)\r
-       MAG_DDR            DDR macro for the reader's port (i.e.. DDRC)\r
-       MAG_PORT           PORT macro for the reader's port (i.e.. PORTC)\r
-\r
-       The example macros listed above assume that the Track 2 data wire is\r
-       connected to pin 0 on port C, the Track 2 clock wire is connected to\r
-       pin 3 on port C (similarly for Tracks 1 and 3), and the card loaded\r
-       wire is connected to pin 4 on port C.\r
-\r
-       If the mag-stripe reader you are using only reads one or two tracks,\r
-       then set the clock and data pins for the tracks it doesn't read to a\r
-       pin that is unused.  For example, on the AT90USBKey, any of the pins on\r
-       port C that do not have wires attached will be unused since they are\r
-       not connected to any onboard devices (such as the joystick or\r
-       temperature sensor).\r
-\r
-       Connecting wires to pins on different ports (i.e.. a data wire to pin 0\r
-       on port C and a clock wire to pin 0 on port D) is currently\r
-       unsupported.  All pins specified above must be on the same port.\r
-*/\r
-\r
-/** \file\r
- *\r
- *  Driver header for a TTL Magnetic Card reader device (such as the Omron V3B-4K).\r
- */\r
-\r
-#ifndef _MAGSTRIPEHW_H_\r
-#define _MAGSTRIPEHW_H_\r
-\r
-       /* Includes: */\r
-               #include <avr/io.h>\r
-\r
-               #include <LUFA/Common/Common.h>\r
-\r
-       /* Private Interface - For use in library only: */\r
-               /* Macros: */\r
-                       /** Mask of the track data, clock and card detection pins. */\r
-                       #define MAG_MASK    (MAG_T1_DATA | MAG_T1_CLOCK | \\r
-                                            MAG_T2_DATA | MAG_T2_CLOCK | \\r
-                                            MAG_T3_DATA | MAG_T3_CLOCK | \\r
-                                            MAG_CARDPRESENT)\r
-\r
-       /* Public Interface - May be used in end-application: */\r
-               /* Inline Functions: */\r
-                       /** Initializes the magnetic stripe card reader ports and pins so that the card reader\r
-                        *  device can be controlled and read by the card reader driver. This must be called before\r
-                        *  trying to read any of the card reader's status lines.\r
-                        */\r
-                       static inline void Magstripe_Init(void)\r
-                       {\r
-                               MAG_DDR  &= ~MAG_MASK;\r
-                               MAG_PORT |=  MAG_MASK;\r
-                       };\r
-\r
-                       /** Returns the status of all the magnetic card reader's outputs.\r
-                        *\r
-                        *  \return A mask indicating which card lines are high or low\r
-                        */\r
-                       static inline uint8_t Magstripe_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
-                       static inline uint8_t Magstripe_GetStatus(void)\r
-                       {\r
-                               /* Mag-stripe IOs are active low and must be inverted when read */\r
-                               return ((uint8_t)~MAG_PIN & MAG_MASK);\r
-                       }\r
-\r
-#endif\r
+/*
+  Copyright 2010  Denver Gingerich (denver [at] ossguy [dot] com)
+  Copyright 2012  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: */
+                       /** Initialises 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
+