A library to read HID RFID cards through the wiegand protocol. This was tested with the HID ProxPoint Plus 6005BG00.

Dependents:   HID_ProxCard_Wiegand_Example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Wiegand.h Source File

Wiegand.h

00001 /* Mbed Wiegand library
00002  * Copyright (c) 2014, 
00003  *      Colin Bookman, cobookman [at] gmail [dot] com 
00004  *      Sarthak Jaiswal sjaiswal3 [at] gatech [dot] edu
00005  *      Avnish Kumar  akumar96 [at] gatech [dot] edu
00006  * 
00007  *  This program is free software: you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation, either version 3 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 #ifndef MBED_MICIO_H
00022 #define MBED_MICIO_H
00023 
00024 #include "mbed.h"
00025 
00026 /**
00027  * @code
00028  * #include "Wiegand.h"
00029  * 
00030  * Wiegand wiegand(pin data0, pin data1, pin hold, onRFIDRead); data0/data1 are ISR Inputs, hold = digital Out
00031  * 
00032  * @endcode
00033  */
00034 class Wiegand  {
00035 public:
00036 
00037     /* Create a Wiegand instance, and attach interrupts */
00038     Wiegand (PinName pdata0, PinName pdata1, PinName pHold, void (*onCardRead)());
00039     
00040     /* Check if we've read all card data */
00041     void doEvents(void);
00042     
00043     /* return number of bits currently read */
00044     uint8_t bitsRead(void);
00045     
00046     /* Returns the bits read from in [start,end] (Inclusive) */
00047     uint64_t getBits(uint8_t start, uint8_t end);
00048     
00049 protected:
00050     InterruptIn _data0ISR;
00051     InterruptIn _data1ISR;
00052     DigitalOut  _hold;
00053     Timer _lastISR;
00054 
00055     void (*_onCardRead)(); //callback function
00056     
00057     /* Internal buffer of wiegand data */
00058     volatile uint8_t _buffer[64];
00059     uint8_t _sizeOfBuffer;
00060     
00061     /* Number of bits currently read */
00062     volatile uint8_t _bitsRead;
00063     
00064     /* Reset buffer */
00065     void _resetBuffer(void);
00066     
00067     /* Attaches ISR Routines */
00068     void _attachInterrupts(void);
00069     
00070     /* ISR Routine for data 0 */    
00071     void _data0ISRAction(void);
00072     
00073     /* ISR Routine for data 1 */
00074     void _data1ISRAction(void);
00075     
00076 };
00077 
00078 #endif