interrupt handling

Dependencies:  

Revision:
11:d5e8f47880f1
Parent:
10:98a58968dc7d
Child:
13:16a5b43ac874
--- a/main.cpp	Thu Apr 09 22:09:35 2015 +0000
+++ b/main.cpp	Fri Apr 10 23:14:55 2015 +0000
@@ -38,12 +38,15 @@
 InterruptIn     readerInt(p7); 
 DigitalOut  testPin(p1);
 BLEDevice  ble;
-uint8_t     buf[300];
+extern uint8_t     buf[300];
 uint8_t noBytes=0;
 extern uint8_t    turnRFOn[2]; 
 extern uint8_t    testcommand[2]; 
-uint8_t     found=4;
+extern uint8_t     found;
+
 bool tagFound=0;
+//uint8_t     WAIT=0;
+
 int main()
 {testPin=0;
 pc.baud(115200);
@@ -63,69 +66,29 @@
 
 readerInt.rise(&handlerNFC);
 CS=1;
-//NFC_SLEEP; 
-//NFC_SLEEP;
-EN2=1;
-//wait_ms(1);
 SpiInit(); //spi=1Mhz
-//PowerUpNFC();
-NFC_ON;
-//wait_ms(1);
-
+PowerUpNFC();
 NFCInit();
 RegisterReInitNFC();
 RegistersReadNFC();
-//wait(1);
-NFC_OFF;
-
+PowerDownNFC();                      //SleepNFC() //StandByNFC()
+//SleepNFC();
 
 while(1)
-{   CS=1;
-    NFC_ON;
-////wait_ms(1);
-NFCInit();
-RegisterReInitNFC();
-MemReadReqNFC();
-if(found==1)
-{
-ReadNFC();
-wait_ms(1);
-NFC_OFF;
-//PowerDownNFC();
-//printf("read single block:");
-for(uint8_t i=0; i<noBytes; i++)
-printf("%X ", buf[i]);
-printf("\r\n");
-found=4;
-}
-else if(found==3)
-{printf("tnf1 \r\n");
-printf("%d ",found);
-found=4;
-}
-//InventoryReqNFC();
-//if(found==1)
-//{
-//ReadNFC();
-//printf("tag id:");
-//for(uint8_t i=0; i<noBytes; i++)
-//printf("%X ", buf[i]);
-//printf("\r\n");
-//found=0;
-//}
-//else 
-//{printf("tnf2 \r\n");
-//}
-wait(1);
+{ 
+tagFound=PollNFC();
+
+if(tagFound==1)
+{//printf("read single block:");
+ for(uint8_t i=0; i<noBytes; i++)
+ printf("%X ", buf[i]);
+ printf("\r\n");
+ printf("tag found \r\n");
+ break;
+ }
+ else wait(1);
+} 
+ 
 }
 
-}  
 
-
-
-
-
-
-
-
-