tim008 tim008
/
WiegandRFID
Nedim Hozić Mesud Klisura
Fork of Wiegand by
main.cpp@0:033aa4854957, 2011-02-03 (annotated)
- Committer:
- pwheels
- Date:
- Thu Feb 03 18:48:04 2011 +0000
- Revision:
- 0:033aa4854957
Initial creation date 3-feb-2011
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pwheels | 0:033aa4854957 | 1 | /* |
pwheels | 0:033aa4854957 | 2 | * Copyright (c) 2011 Paul van der Wielen, Pro-Serv |
pwheels | 0:033aa4854957 | 3 | * |
pwheels | 0:033aa4854957 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
pwheels | 0:033aa4854957 | 5 | * of this software and associated documentation files (the "Software"), to use |
pwheels | 0:033aa4854957 | 6 | * and implement the software for none commercial reason and usage only and |
pwheels | 0:033aa4854957 | 7 | * subject to the following conditions: |
pwheels | 0:033aa4854957 | 8 | * |
pwheels | 0:033aa4854957 | 9 | * The above copyright notice and this permission notice shall be included in |
pwheels | 0:033aa4854957 | 10 | * all copies or substantial portions of the Software. |
pwheels | 0:033aa4854957 | 11 | * |
pwheels | 0:033aa4854957 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
pwheels | 0:033aa4854957 | 13 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
pwheels | 0:033aa4854957 | 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
pwheels | 0:033aa4854957 | 15 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
pwheels | 0:033aa4854957 | 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
pwheels | 0:033aa4854957 | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
pwheels | 0:033aa4854957 | 18 | * THE SOFTWARE. |
pwheels | 0:033aa4854957 | 19 | * |
pwheels | 0:033aa4854957 | 20 | * Usage and assumptions: |
pwheels | 0:033aa4854957 | 21 | * a RFID reader Model MF7(1.05) is configured in wiegand mode and attached |
pwheels | 0:033aa4854957 | 22 | * ports per call to class (could be to p5 & p6 via a level converter as to |
pwheels | 0:033aa4854957 | 23 | * isolate the 5V source voltage from the 3.3V needed by MCU, this can easily |
pwheels | 0:033aa4854957 | 24 | * be done with diode in series with signal data0 and data1 of RFID reader and |
pwheels | 0:033aa4854957 | 25 | * pull up on MCU side. |
pwheels | 0:033aa4854957 | 26 | */ |
pwheels | 0:033aa4854957 | 27 | |
pwheels | 0:033aa4854957 | 28 | #include "mbed.h" |
pwheels | 0:033aa4854957 | 29 | #include "wiegand.h" |
pwheels | 0:033aa4854957 | 30 | |
pwheels | 0:033aa4854957 | 31 | DigitalOut flash(LED4); |
pwheels | 0:033aa4854957 | 32 | |
pwheels | 0:033aa4854957 | 33 | Wiegand wiegand(p5,p6); |
pwheels | 0:033aa4854957 | 34 | |
pwheels | 0:033aa4854957 | 35 | int main() { |
pwheels | 0:033aa4854957 | 36 | |
pwheels | 0:033aa4854957 | 37 | while(1) { |
pwheels | 0:033aa4854957 | 38 | if (wiegand.readable()) { |
pwheels | 0:033aa4854957 | 39 | // output our data read from rfid card reader to usb port for display |
pwheels | 0:033aa4854957 | 40 | // purposes |
pwheels | 0:033aa4854957 | 41 | printf ("Site = %x\r\n", wiegand.site()); |
pwheels | 0:033aa4854957 | 42 | printf ("Data = %x\r\n", wiegand.data()); |
pwheels | 0:033aa4854957 | 43 | printf ("RFID = %x\r\n", wiegand.rfid()); |
pwheels | 0:033aa4854957 | 44 | wiegand.clear(); |
pwheels | 0:033aa4854957 | 45 | } |
pwheels | 0:033aa4854957 | 46 | flash = !flash; |
pwheels | 0:033aa4854957 | 47 | wait(0.25); |
pwheels | 0:033aa4854957 | 48 | } |
pwheels | 0:033aa4854957 | 49 | } |