rtgvc

Dependencies:   MFRC522_new mbed

Fork of Reading_RFID_MFRC522_WIZWiki_W7500 by Biswajit Padhi

Revision:
2:f9b1dba474a0
Parent:
1:27fb38198323
--- a/main.cpp	Thu Apr 13 05:33:25 2017 +0000
+++ b/main.cpp	Thu Feb 22 10:25:01 2018 +0000
@@ -43,7 +43,7 @@
 void DumpMifareClassicToSerial      (MFRC522::Uid *uid, uint8_t piccType, MFRC522::MIFARE_Key *key);
 void DumpMifareClassicSectorToSerial(MFRC522::Uid *uid, MFRC522::MIFARE_Key *key, uint8_t sector);
 void DumpMifareUltralightToSerial   (void);
-
+uint8_t page;
 /**
  * Dumps debug info about the selected PICC to Serial.
  * On success the PICC is halted after dumping the data.
@@ -54,7 +54,7 @@
 void DumpToSerial(MFRC522::Uid *uid)
 {
     MFRC522::MIFARE_Key key;
-
+    
     // Print Card UID
     printf("Card UID: ");
     for (uint8_t i = 0; i < RfChip.uid.size; i++) {
@@ -65,7 +65,7 @@
     // Print Card type
     uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
     printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType));
-    wait_ms(1000);
+    wait_ms(50);
 
     // Dump contents
     switch (piccType) {
@@ -290,9 +290,12 @@
     uint8_t buffer[18];
     uint8_t i;
 
+
+/*uint8_t len=(MFRC522::StatusCode)RfChip.MIFARE_UltralightWrite(sizeof(page), buffer, 4);
+    pc.printf("Page size: %d \n",len);*/
     printf("Page   0  1  2  3");
     // Try the mpages of the original Ultralight. Ultralight C has more pages.
-    for (uint8_t page = 0; page < 16; page +=4) {
+    for ( page = 0; page < 16; page +=4) {
         // Read pages
         byteCount = sizeof(buffer);
         status = RfChip.MIFARE_Read(page, buffer, &byteCount);
@@ -331,29 +334,29 @@
     printf("\n\r");
 
     while(1) {
-        LedRed   = 1;
-        LedGreen = 1;
+      
+        LedGreen = 0;
 
         // Look for new cards
         if ( ! RfChip.PICC_IsNewCardPresent()) {
-            wait_ms(500);
-            continue;
-        }
-
-        LedRed   = 0;
-
-        // Select one of the cards
-        if ( ! RfChip.PICC_ReadCardSerial()) {
-            wait_ms(500);
+            wait_ms(50);
             continue;
         }
 
         LedRed   = 1;
+
+        // Select one of the cards
+        if ( ! RfChip.PICC_ReadCardSerial()) {
+            wait_ms(50);
+            continue;
+        }
+
+    
         LedGreen = 0;
 
         // Dump debug info about the card. PICC_HaltA() is automatically called.
         DumpToSerial(&(RfChip.uid));
-        wait_ms(200);
+        wait_ms(50);
 
     }
 }
\ No newline at end of file