interrupt handling
main.cpp
- Committer:
- soumi_ghsoh
- Date:
- 2015-04-02
- Revision:
- 6:3c510c297e2f
- Parent:
- 5:93c612f43ec2
- Child:
- 7:96baf1b2fd07
File content as of revision 6:3c510c297e2f:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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" #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 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 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 debugBuffer[1000]; // Capture data for analysis uint8_t bufIdx=0; extern uint8_t turnRFOn[2]; extern uint8_t testcommand[2]; int main() { pc.baud(115200); PowerUpNFC(); SpiInit(); //spi=1Mhz NFCInit(); wait_ms(1); RegisterReInitNFC(); RegistersReadNFC(); // testPin=0; while(1) {InventoryReqNFC(); //ReadNFC(); //wait_ms(20); } } //// 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()