-

Dependents:   GPSXbee_1_1 GPSXbee_1_0

Beacon.h

Committer:
Deurklink
Date:
2014-12-16
Revision:
1:d4cbfcb2be46
Parent:
0:8b33ba38cc3a

File content as of revision 1:d4cbfcb2be46:

#include "mbed.h"
#include <string>
#include "GPS.h"
#include "EthernetPowerControl.h"
#include "MODSERIAL.h"
#include "SDFileSystem.h"

#define XBEETIMEOUT 5

class Beacon
{
public:
    Beacon(PinName gpsTx, PinName gpsRx, PinName xbTx, PinName xbRx, int freq, int len);
    GPS gps;
    SDFileSystem sd;
    bool init();
    void parseXbee();
    void parseGpsData();
    bool gpsReadable();
    bool xbeeReadable();

    DigitalOut L1;
    DigitalOut L2;
    DigitalOut L3;
    DigitalOut L4;  
    
private:
    MODSERIAL XBee;
    InterruptIn PPS;    
    char RxBuffer[256];
    
    bool PWMon;
    bool RxTO;
       
    int TimingOffset;
    int BeaconNumber;
   
    void ppsSync();
    void readDipSwitch();
    void initDipSwitch();
    
    bool initSD();
    bool SDEnabled;
    // SD card detect pin
    DigitalIn CD;
   
    // Pins are all bound to a mbed pin in the constructor
    // Digital pins for setting the Timing offset
    DigitalIn T1;
    DigitalIn T2;
    DigitalIn T3;
    DigitalIn T4;
    DigitalIn T5;
    DigitalIn T6;
    DigitalIn T7;
    DigitalIn T8;

    // Digital pins for setting the beacon number
    DigitalIn B1;
    DigitalIn B2;
    DigitalIn B3;
    DigitalIn B4;
    
    int PulseFrequency;   //Hz
    int Pulselength; //usec
    int PWMclock; 
    int Period;
    

    Timeout _RxTimeOut;
    void rxTimeOut();
    
    void startPWM();
    void stopPWM();
    void resetPWM(int _PulseFrequency, int _Pulselength);
    void printStatus();
    void getXbeeData();  
};