interrupt handling

Dependencies:  

main.cpp

Committer:
soumi_ghsoh
Date:
2015-04-10
Revision:
11:d5e8f47880f1
Parent:
10:98a58968dc7d
Child:
13:16a5b43ac874

File content as of revision 11:d5e8f47880f1:

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    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;
extern uint8_t     buf[300];
uint8_t noBytes=0;
extern uint8_t    turnRFOn[2]; 
extern uint8_t    testcommand[2]; 
extern uint8_t     found;

bool tagFound=0;
//uint8_t     WAIT=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;
SpiInit(); //spi=1Mhz
PowerUpNFC();
NFCInit();
RegisterReInitNFC();
RegistersReadNFC();
PowerDownNFC();                      //SleepNFC() //StandByNFC()
//SleepNFC();

while(1)
{ 
tagFound=PollNFC();

if(tagFound==1)
{//printf("read single block:");
 for(uint8_t i=0; i<noBytes; i++)
 printf("%X ", buf[i]);
 printf("\r\n");
 printf("tag found \r\n");
 break;
 }
 else wait(1);
} 
 
}