interrupt handling
main.cpp
- Committer:
- soumi_ghsoh
- Date:
- 2015-04-09
- Revision:
- 10:98a58968dc7d
- Parent:
- 9:9266e0109d26
- Child:
- 11:d5e8f47880f1
File content as of revision 10:98a58968dc7d:
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 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 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 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=4; 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); CS=1; //NFC_SLEEP; //NFC_SLEEP; EN2=1; //wait_ms(1); SpiInit(); //spi=1Mhz //PowerUpNFC(); NFC_ON; //wait_ms(1); NFCInit(); RegisterReInitNFC(); RegistersReadNFC(); //wait(1); NFC_OFF; while(1) { CS=1; NFC_ON; ////wait_ms(1); NFCInit(); RegisterReInitNFC(); MemReadReqNFC(); if(found==1) { ReadNFC(); 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=4; } else if(found==3) {printf("tnf1 \r\n"); printf("%d ",found); found=4; } //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); } }