An example writing URI info to NUCLEO-NFC01A1 board

Dependencies:   NUCLEO-NFC01A1 lib_NFC_M24SR lib_NFC_NDEF mbed

Fork of Nucleo_NFC_Example by Enrico Gregoratto

Warning: Deprecated!

Supported drivers and applications can be found at this link.

Revision:
0:d0dc2034ee2a
Child:
2:f32244d8aff8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 15 19:42:37 2014 +0000
@@ -0,0 +1,99 @@
+#include "mbed.h"
+#include "lib_TagType4.h"
+
+//------------------------------------
+// Hyperterminal configuration
+// 9600 bauds, 8-bit data, no parity
+//------------------------------------
+Serial pc(SERIAL_TX, SERIAL_RX);
+// LED1
+DigitalOut myled(LED1);
+DigitalOut nfcled1(D5);
+DigitalOut nfcled2(D4);
+DigitalOut nfcled3(D2);
+
+#define TT4_INITS_RETRYS 5
+
+int main() {
+  sURI_Info URIout;
+  sURI_Info URIin;
+  
+  memset(&URIin, 0x00, sizeof(URIin));
+  
+  nfcled1 = 0;
+  nfcled2 = 0;
+  nfcled3 = 0;
+  
+  pc.printf("NFC Example\n");
+  
+  pc.printf("Prepare URI NDEF message content\n");
+  // Prepare URI NDEF message content
+  strcpy(URIout.protocol,URI_ID_0x01_STRING);
+  strcpy(URIout.URI_Message,"st.com");
+  strcpy(URIout.Information,"\0");
+  
+  pc.printf("Done\n");
+  pc.printf("URIout:\n");
+  pc.printf("URIout.protocol=%d\n", URIout.protocol);
+  pc.printf("URIout.URI_Message=%s\n", URIout.URI_Message);
+  
+  
+  printf("Initializing Tag Type 4\n");
+  int BlinkLED = 0;
+  while(TT4_Init()!=SUCCESS)
+  {
+        if(BlinkLED<100)
+        {
+            BlinkLED++;
+        }
+        else
+        {
+            BlinkLED=0;
+            nfcled1 = !nfcled1;
+        }
+  }
+  nfcled1 = 1;
+  
+  // Write URI
+  BlinkLED = 0;
+  while (TT4_WriteURI(&URIout) != SUCCESS)
+  {
+    if(BlinkLED<100)
+    {
+        BlinkLED++;
+    }
+    else
+    {
+        BlinkLED=0;
+        nfcled2 = !nfcled2;
+    }
+  }
+  nfcled2 = 1;
+  
+  // Read URI
+  BlinkLED = 0;
+  while(TT4_ReadURI(&URIin) != SUCCESS)
+  {
+     if(BlinkLED<100)
+    {
+        BlinkLED++;
+    }
+    else
+    {
+        BlinkLED=0;
+        nfcled3 = !nfcled3;
+    } 
+  }
+  nfcled3 = 1;
+  
+  pc.printf("URIin.protocol=%d\n", URIin.protocol);
+  pc.printf("URIin.URI_Message=%s\n", URIin.URI_Message);
+  
+  
+  LOOPFOREVER:
+  
+  while(1) { 
+      wait(0.5);
+      myled = !myled;
+  }
+}