grove nfc_tag sample program

Dependencies:   mbed

Revision:
1:c492babe8dc3
Parent:
0:b939441bcdc7
diff -r b939441bcdc7 -r c492babe8dc3 main.cpp
--- a/main.cpp	Tue Mar 28 10:21:09 2017 +0000
+++ b/main.cpp	Fri Mar 31 11:20:13 2017 +0000
@@ -1,12 +1,28 @@
 #include "mbed.h"
+#include "nfc_tag.h"
 
-DigitalOut myled(LED1);
+#define NFC_ADRESS 0x53
+//rx2 tx2
+NfcTag nfcTag_cons(p28,p27,NFC_ADRESS<<1,USER_MODE);
+bool flag = false;
+bool preFlag = false;
 
-int main() {
-    while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+int main()
+{
+    //nfcTag = NfcTag(p15,p14);
+    while(true) {
+        printf("*****");
+        flag = nfcTag_cons.readuint8_t(EEPROM_I2C_LENGTH-1) == 0xff?true:false;// read 0x07ff block address
+        printf(" %x ",nfcTag_cons.readuint8_t(EEPROM_I2C_LENGTH-1));
+        if(flag != preFlag) {
+            printf("get remote NFC control signal!");
+            if(flag == true) {
+                printf("led will light up!");
+            } else {
+                printf("led will turn dark!");
+            }
+            preFlag = flag;
+        }
+        wait(1);
     }
-}
+}
\ No newline at end of file