mbed code for the Kinoma team's wireless assignment

Dependencies:   mbed

Fork of idd_hw5_kinoma_rememberkeys by Sean McQueen

Revision:
0:372076a79d90
diff -r 000000000000 -r 372076a79d90 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Nov 09 21:23:55 2014 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "Adafruit_PN532.h"
+
+#define SS   PTD0
+// PTD1 is also LED_BLUE, it will blink during SPI communication.
+#define SCK  PTD1
+#define MOSI PTD2
+#define MISO PTD3
+
+DigitalOut kinoma(D8);
+int previous = 0;
+
+Adafruit_PN532 nfc(SCK, MISO, MOSI, SS);
+
+void loop(void);
+
+int main() {
+  kinoma = 0;
+  nfc.begin();
+
+  uint32_t versiondata = nfc.getFirmwareVersion();
+  if (! versiondata) {
+    while (1); // halt
+  }
+
+  nfc.SAMConfig();
+  
+  while(1) { loop(); }
+}
+
+
+void loop(void) {
+  uint8_t success;
+  uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  
+  uint8_t uidLength;                        
+  
+  success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
+  
+  if (success) {
+    previous = 1;
+
+    if (uidLength == 4)
+    {
+        uint8_t tag_1 = 250;
+        uint8_t tag_2 = 186;
+        uint8_t tag_3 = 106;
+        uint8_t tag_4 = 10;
+        kinoma = 1;
+    }
+  } else if (previous == 0){
+     kinoma = 0;
+     } else {
+     previous = 0; 
+    }
+}
\ No newline at end of file