interrupt handling
main.cpp
- Committer:
- soumi_ghsoh
- Date:
- 2015-04-08
- Revision:
- 9:9266e0109d26
- Parent:
- 7:96baf1b2fd07
- Child:
- 10:98a58968dc7d
File content as of revision 9:9266e0109d26:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 "BLEDevice.h" #include "HeartRateService.h" #include "DeviceInformationService.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); BLEDevice ble; uint8_t buf[300]; uint8_t noBytes=0; extern uint8_t turnRFOn[2]; extern uint8_t testcommand[2]; uint8_t found=0; bool tagFound=0; int main() {testPin=0; pc.baud(115200); //=============================================================ble test ble.init(); // ble.onDisconnection(disconnectionCallback); // // /* Setup advertising. */ ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); // // ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, (uint8_t *)uuid16_list, sizeof(uuid16_list)); ble.accumulateAdvertisingPayload(GapAdvertisingData::GENERIC_HEART_RATE_SENSOR); // // ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED); ble.setAdvertisingInterval(1000); ble.startAdvertising(); //===============================================================*/ readerInt.rise(&handlerNFC); SpiInit(); //spi=1Mhz PowerUpNFC2(); NFCInit(); //wait_ms(1); //RegisterReInitNFC(); //RegistersReadNFC(); //wait_ms(10); //PowerDownNFC(); //wait(10); // //PowerUpNFC2(); //NFCInit(); //// //wait_ms(1); //RegisterReInitNFC(); //RegistersReadNFC(); //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(); MemReadReqNFC(); if(found==1) { ReadNFC(); PowerDownNFC(); //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"); //} wait(1); } }