interrupt handling
Diff: main.cpp
- Revision:
- 10:98a58968dc7d
- Parent:
- 9:9266e0109d26
- Child:
- 11:d5e8f47880f1
--- a/main.cpp Wed Apr 08 20:48:05 2015 +0000 +++ b/main.cpp Thu Apr 09 22:09:35 2015 +0000 @@ -29,7 +29,9 @@ DigitalOut debug2LED(LED2); // "Debug2" LED DigitalOut ISO15693LED(LED3); // "Detected ISO15693 tag" LED DigitalOut debug1LED(LED1); // "Debug1" LED - +extern DigitalOut EN; // Control EN pin on TRF7970 +extern DigitalOut EN2; // Control EN2 pin on TRF7970 +extern DigitalOut CS; //DigitalInOut ook_ask(p6); // Control ASK/OOK pin on TRF7970 //DigitalOut mod(p5); // Control MOD pin on TRF7970 @@ -40,12 +42,11 @@ uint8_t noBytes=0; extern uint8_t turnRFOn[2]; extern uint8_t testcommand[2]; -uint8_t found=0; +uint8_t found=4; bool tagFound=0; int main() {testPin=0; pc.baud(115200); - //=============================================================ble test ble.init(); // ble.onDisconnection(disconnectionCallback); @@ -61,61 +62,46 @@ //===============================================================*/ readerInt.rise(&handlerNFC); +CS=1; +//NFC_SLEEP; +//NFC_SLEEP; +EN2=1; +//wait_ms(1); SpiInit(); //spi=1Mhz -PowerUpNFC2(); +//PowerUpNFC(); +NFC_ON; +//wait_ms(1); NFCInit(); -//wait_ms(1); -//RegisterReInitNFC(); -//RegistersReadNFC(); -//wait_ms(10); -//PowerDownNFC(); -//wait(10); -// -//PowerUpNFC2(); -//NFCInit(); -//// -//wait_ms(1); -//RegisterReInitNFC(); - -//RegistersReadNFC(); - +RegisterReInitNFC(); +RegistersReadNFC(); +//wait(1); +NFC_OFF; - -//wait_ms(10); -//PowerUpNFC(); while(1) -{PowerUpNFC2(); - NFCInit(); -//wait_ms(1); -//RegisterReInitNFC(); -//RegistersReadNFC(); -//turnRFOn[0] = CHIP_STATUS_CONTROL; -//turnRFOn[1] = CHIP_STATUS_CONTROL; -//// -//turnRFOn[1] &= 0x3F; -//turnRFOn[1] |= 0x20; -//trf797xWriteSingle(turnRFOn, 2); -//////wait_ms(2); -//// -//testcommand[0] = ISO_CONTROL; -//testcommand[1] = 0x02; // 6.78 MHz, OOK 100% -//trf797xWriteSingle(testcommand, 2); -//RegisterReInitNFC(); +{ CS=1; + NFC_ON; +////wait_ms(1); +NFCInit(); +RegisterReInitNFC(); MemReadReqNFC(); if(found==1) { ReadNFC(); -PowerDownNFC(); +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=0; +found=4; } -else +else if(found==3) {printf("tnf1 \r\n"); +printf("%d ",found); +found=4; } //InventoryReqNFC(); //if(found==1)