Dependencies: ros_lib_kinetic
Diff: LLComms.h
- Revision:
- 8:d6657767a182
- Child:
- 9:cd3607ba5643
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LLComms.h Tue Aug 07 09:18:15 2018 +0000 @@ -0,0 +1,57 @@ +// LLComms.h + +#ifndef LLCOMMS_H +#define LLCOMMS_H + +// STANDARD IMPORTS +// MBED IMPORTS +#include "mbed.h" +#include "mbed_events.h" + +// ADC SPI DEFINES +#define PREAMBLE 0x06 +#define CHAN_1 0x30 +#define CHAN_2 0x70 +#define CHAN_3 0xB0 +#define CHAN_4 0xF0 +#define DATA_MASK 0x0F + +class LLComms +{ + public: + + // PIN DECLARATIONS + InterruptIn pinGate6; // This pin HAS TO BE defined before SPI set up. No Clue Why. + SPI spi; // mosi, miso, sclk + DigitalOut* cs_LL[8]; // Chip select for low level controller + DigitalOut* cs_ADC[8]; // Chip select for ADC + DigitalOut pinCheck; + // These interrupt pins have to be declared AFTER SPI declaration. No Clue Why. + InterruptIn pinGate0; + InterruptIn pinGate1; + InterruptIn pinGate2; + InterruptIn pinGate3; + InterruptIn pinGate4; + InterruptIn pinGate5; + InterruptIn pinGate7; + DigitalOut pinReset; // Reset pin for all controllers. + + Mutex mutChannel[8]; + int ThreadID[8]; + + char chrErrorFlag[8];// 3 error bits from LL + + LLComms(int low_level_spi_frequency); + //void SendReceiveData(int channel, int _intDemandPos_Tx[], bool *isDataReady[]); + + private: + + const short int _n_channels = 8; + int _spi_frequency; + + double ReadADCPosition_mtrs(int channel); + double ReadADCPressure_bar(int channel); + +}; + +#endif \ No newline at end of file