project van rtos

Dependencies:   mbed-os

Fork of MFRC522 by Martin Olejar

Revision:
7:1c712013123b
Parent:
5:e45681989201
Child:
8:4638e3f14c41
--- a/main.cpp	Tue May 15 14:02:11 2018 +0000
+++ b/main.cpp	Thu May 17 11:01:22 2018 +0000
@@ -315,6 +315,39 @@
     }
 }
 
+void checkRFID() {
+  while (true) {  
+
+    // Look for new cards
+    if ( ! RfChip.PICC_IsNewCardPresent())
+    {
+      Thread::wait(500);
+      continue;
+    }
+
+    // Select one of the cards
+    if ( ! RfChip.PICC_ReadCardSerial())
+    {
+      Thread::wait(500);
+      continue;
+    }
+
+    // Print Card UID
+    pc.printf("Card UID: ");
+    for (uint8_t i = 0; i < RfChip.uid.size; i++)
+    {
+      pc.printf(" %X02", RfChip.uid.uidByte[i]);
+    }
+    pc.printf("\n\r");
+
+    // Print Card type
+    uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
+    pc.printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType));
+    Thread::wait(1000);
+  }
+}
+    
+
 int main(void) {
   pc.printf("Start");
   
@@ -330,6 +363,8 @@
   Thread thread_display(osPriorityRealtime);
   thread_display.start(displayNumber7Seg);
   
+  Thread thread_rfid;
+  thread_rfid.start(checkRFID);
   // Set debug UART speed
   //pc.baud(115200);
 
@@ -342,10 +377,7 @@
     dg3 = 0;
 
   while (true) {  
-    
-    //displayNumber7Seg(sensorValue);
 
-    //printf("%0.4f \n\r", a0.read());
     // Look for new cards
     /*if ( ! RfChip.PICC_IsNewCardPresent())
     {