tim008 tim008
/
WiegandRFID
Nedim Hozić Mesud Klisura
Fork of Wiegand by
Diff: wiegand.h
- Revision:
- 1:024f831fa51e
- Parent:
- 0:033aa4854957
--- a/wiegand.h Thu Feb 03 18:48:04 2011 +0000 +++ b/wiegand.h Sun Jan 19 14:19:09 2014 +0000 @@ -32,6 +32,7 @@ */ #include "mbed.h" +#define W_PULSES 26 class Wiegand { public: @@ -46,11 +47,11 @@ * Interrupt driven signal from data0 data line */ void data_0() { - if (_pulses == 26) { + if (_pulses == W_PULSES) { clear(); } _wiegand = ((_wiegand << 1) & 0x3ffffff) + 0x00; - if (_pulses < 13) { + if (_pulses < W_PULSES / 2) { _e_par = (_e_par & 0x01); } else { _e_par = (_e_par & 0x01); @@ -62,11 +63,11 @@ * Interrupt driven signal from data1 data line */ void data_1() { - if (_pulses == 26) { + if (_pulses == W_PULSES) { clear(); } _wiegand = ((_wiegand << 1) & 0x3ffffff) + 0x01; - if (_pulses < 13) { + if (_pulses < W_PULSES / 2) { _o_par = (_o_par & 0x01) + 0x01; } else { _o_par = (_o_par & 0x01) + 0x01; @@ -93,7 +94,7 @@ * returns true if we have read all pulses and we have proper parity for both data halves */ bool readable() { - if (( _pulses == 26) && (_e_par == 0) && (_o_par == 1)) { + if (( _pulses == W_PULSES) && (_e_par == 0) && (_o_par == 1)) { return true; } else { return false;