interrupt handling

Dependencies:  

Revision:
7:96baf1b2fd07
Parent:
6:3c510c297e2f
Child:
9:9266e0109d26
--- a/main.cpp	Thu Apr 02 21:10:48 2015 +0000
+++ b/main.cpp	Tue Apr 07 20:06:51 2015 +0000
@@ -19,8 +19,7 @@
 
 //#include    "NFC_7970.h"
 #include    "readerComm.h"
-#include    "interruptStuff.h"
-#include "HardwareTimer.h"
+
 SPI         spi(p25, p28, p29); // MOSI, MISO, SCLK
            // Slave Select (SS)
 Serial      pc(USBTX, USBRX);   // Serial communication over USB with PC
@@ -28,46 +27,55 @@
 DigitalOut  debug2LED(LED2);    // "Debug2" LED
 DigitalOut  ISO15693LED(LED3);  // "Detected ISO15693 tag" LED
 DigitalOut  debug1LED(LED1);    // "Debug1" LED
-DigitalInOut  ook_ask(p6);      // Control ASK/OOK pin on TRF7970
-DigitalOut  mod(p5);            // Control MOD pin on TRF7970
-
+//DigitalInOut  ook_ask(p6);      // Control ASK/OOK pin on TRF7970
+//DigitalOut  mod(p5);            // Control MOD pin on TRF7970
+InterruptIn     readerInt(p7); 
 DigitalOut  testPin(p1);
 
-uint8_t     buffer[2];
-int8_t      rxtxState = 1;      // Transmit/Receive byte count
 uint8_t     buf[300];
-uint8_t     irqRegister = 0x01; // Interrupt register
-volatile uint8_t     irqFlag = 0x00;
-uint8_t     rxErrorFlag = 0x00;
-uint8_t     readerMode;         // Determines how interrupts will be handled
-int16_t     nfc_state;
-uint8_t     nfc_protocol;
-uint8_t     active;
-uint8_t     tagFlag;
-uint8_t     irqCount = 0;
+uint8_t noBytes=0;
 
-uint8_t     debugBuffer[1000];  // Capture data for analysis
-uint8_t     bufIdx=0;
-extern uint8_t    turnRFOn[2];  
-
-extern uint8_t    testcommand[2];
-
-
+uint8_t     found=0;
+bool tagFound=0;
 int main()
 {
 pc.baud(115200);
+readerInt.rise(&handlerNFC);
 PowerUpNFC();
 SpiInit(); //spi=1Mhz
 NFCInit();
 wait_ms(1);
 RegisterReInitNFC();
 RegistersReadNFC();
-//
-testPin=0;
 while(1)
-{InventoryReqNFC();
-//ReadNFC();
-//wait_ms(20);
+{
+MemReadReqNFC();
+if(found==1)
+{
+ReadNFC();
+
+printf("read single block:");
+for(uint8_t i=0; i<noBytes; i++)
+printf("%X ", buf[i]);
+printf("\r\n");
+found=0;
+}
+else 
+{printf("tnf1 \r\n");
+}
+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");
+}
 }
 }