Mid level control code
Dependencies: ros_lib_kinetic
LLComms.h
00001 // LLComms.h 00002 00003 #ifndef LLCOMMS_H 00004 #define LLCOMMS_H 00005 00006 // STANDARD IMPORTS 00007 #include "math.h" 00008 #include <algorithm> 00009 // MBED IMPORTS 00010 #include "mbed.h" 00011 #include "mbed_events.h" 00012 // CUSTOM IMPORTS 00013 #include "MLSettings.h" 00014 00015 // ADC SPI DEFINES 00016 #define PREAMBLE 0x06 00017 #define CHAN_1 0x30 00018 #define CHAN_2 0x70 00019 #define CHAN_3 0xB0 00020 #define CHAN_4 0xF0 00021 #define DATA_MASK 0x0F 00022 00023 class LLComms 00024 { 00025 00026 public: 00027 00028 EventQueue queue; 00029 Mutex mutChannel[N_CHANNELS]; 00030 bool isDataReady[N_CHANNELS]; // Flag to indicate path data is ready for transmission to low level. 00031 double demandPosition_mm[N_CHANNELS]; 00032 double demandSpeed_mmps[N_CHANNELS]; 00033 char chrErrorFlag[N_CHANNELS]; // 3 error bits from LL 00034 unsigned int positionSensor_uint[N_CHANNELS]; 00035 double positionSensor_mm[N_CHANNELS]; // The actual chamber lengths in meters given as the change in length relative to neutral (should always be >=0) 00036 unsigned int pressureSensor_uint[N_CHANNELS]; 00037 double pressureSensor_bar[N_CHANNELS]; // The pressure in a given chamber in bar (1 bar = 100,000 Pa) 00038 00039 LLComms(); // Constructor 00040 //~LLComms(); // Destructor 00041 00042 private: 00043 00044 // PIN DECLARATIONS 00045 InterruptIn pinGate6; // This pin HAS TO BE defined before SPI set up. No Clue Why. 00046 SPI spi_0; // mosi, miso, sclk 00047 SPI spi_1; 00048 SPI spi_2; 00049 DigitalOut* cs_LL[N_CHANNELS]; // Chip select for low level controller 00050 //DigitalOut* cs_ADC[N_CHANNELS]; // Chip select for ADC 00051 // These interrupt pins have to be declared AFTER SPI declaration. No Clue Why. 00052 InterruptIn pinGate0; 00053 InterruptIn pinGate1; 00054 InterruptIn pinGate2; 00055 InterruptIn pinGate3; 00056 InterruptIn pinGate4; 00057 InterruptIn pinGate5; 00058 InterruptIn pinGate7; 00059 InterruptIn pinGate8; 00060 DigitalOut pinReset; // Reset pin for all controllers. 00061 00062 int ThreadID[N_CHANNELS]; 00063 00064 unsigned int formatMessage(short int type, double dblValue, double dblMaxValue); 00065 //bool CheckMessage(int msg, short int trueType); 00066 bool CheckMessage(int msg); 00067 bool PerformMasterSPI(SPI *spi, unsigned int outboundMsgs[], unsigned int inboundMsgsData[]); 00068 void SendReceiveData(int channel); 00069 void common_rise_handler(int channel); 00070 void common_fall_handler(int channel); 00071 void rise0(void); 00072 void rise1(void); 00073 void rise2(void); 00074 void rise3(void); 00075 void rise4(void); 00076 void rise5(void); 00077 void rise6(void); 00078 void rise7(void); 00079 void rise8(void); 00080 void fall0(void); 00081 void fall1(void); 00082 void fall2(void); 00083 void fall3(void); 00084 void fall4(void); 00085 void fall5(void); 00086 void fall6(void); 00087 void fall7(void); 00088 void fall8(void); 00089 00090 }; 00091 00092 #endif
Generated on Mon Jul 25 2022 18:11:35 by
1.7.2