Wiegand compatible RFID reader class

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
pwheels
Date:
Sun Jan 19 14:19:09 2014 +0000
Parent:
0:033aa4854957
Commit message:
no detail

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
wiegand.h Show annotated file Show diff for this revision Revisions of this file
--- a/mbed.bld	Thu Feb 03 18:48:04 2011 +0000
+++ b/mbed.bld	Sun Jan 19 14:19:09 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/9a9732ce53a1
+http://mbed.org/users/mbed_official/code/mbed/builds/4c0c40fd0593
\ No newline at end of file
--- 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;