interrupt handling
main.cpp
- Committer:
- soumi_ghsoh
- Date:
- 2015-04-07
- Revision:
- 7:96baf1b2fd07
- Parent:
- 6:3c510c297e2f
- Child:
- 9:9266e0109d26
File content as of revision 7:96baf1b2fd07:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Filename: main.cpp Description: Interface nRF51-DK eval board to TRF7970 eval board to test the suitability of the TRF7970 NFC chip for use in Gymtrack products. The nRF51-DK board has an nRF51422 MCU. Copyright (C) 2015 Gymtrack, Inc. Author: Ron Clough Date: 2015-02-26 Changes: Rev Date Who Details ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 0.0 2015-02-26 RWC Original version. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "mbed.h" //#include "NFC_7970.h" #include "readerComm.h" SPI spi(p25, p28, p29); // MOSI, MISO, SCLK // Slave Select (SS) Serial pc(USBTX, USBRX); // Serial communication over USB with PC DigitalOut heartbeatLED(LED4); // "Heartbeat" LED 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 InterruptIn readerInt(p7); DigitalOut testPin(p1); uint8_t buf[300]; uint8_t noBytes=0; 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(); while(1) { 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"); } } } //// Setup LEDs // heartbeatLED = LED_OFF; // ISO15693LED = LED_OFF; // debug1LED = LED_OFF; // debug2LED = LED_OFF; //for (uint8_t i=0; i<4; i++) { // heartbeatLED = LED_ON; // ISO15693LED = LED_ON; // debug1LED = LED_ON; // wait_ms(100); // heartbeatLED = LED_OFF; // ISO15693LED = LED_OFF; // debug1LED = LED_OFF; // wait_ms(100); // } // // Ticker heartbeat; // heartbeat.attach(blinkHeartbeatLED, 1); // printf("LEDs, "); //=============================================================== // Setup the SPI interface // spi.format(8, 1); // 8 bit data, mode = 1 (transition on rising edge, sample on falling edge) // spi.frequency(1000000); // SCLK = 1 MHz //// printf("SPI, "); // // // Set On-Off Keying modulation // ook_ask.output(); // ook_ask = 1; //// printf("OOK, "); // // // Apply initial settings to the TRF7970 // testPin=1; // trf797xInitialSettings(); //// printf("Initialized, "); // testPin=0; // // Tri-state OOK pin // ook_ask.input(); // ook_ask.mode(PullUp); // // readerMode = 0x00; //============================================================= /* // Test: Write 0xAA to MODULATOR_CONTROL, then verify by reading MODULATOR_CONTROL. // printf("\r\n"); buffer[0] = MODULATOR_CONTROL; buffer[1] = 0xAA; // printf("BEFORE WR: buffer[0]: %X buffer[1]: %X\r\n", buffer[0], buffer[1]); spiWriteSingle(buffer, 2); // printf("AFTER WR: buffer[0]: %X buffer[1]: %X\r\n", buffer[0], buffer[1]); spiReadSingle(buffer, 1); // printf("AFTER RD: buffer[0]: %X buffer[1]: %X\r\n", buffer[0], buffer[1]); // printf("\r\n"); */ // printf("\r\nFinished Init\r\n"); // Setup interrupt from TRF7970 // testPin=1; //======================== // trf797xSetupIrq(); //====================== // testPin=0; // printf("IRQ setup, "); // printf("finished init.\r\n\r\n"); // while(1) { // changed TRUE to 1 $SG // iso15693FindTag(); // } // //} // End of main()