Mid level control code

Dependencies:   ros_lib_kinetic

Revision:
26:7c59002c9cd7
Parent:
24:bc852aa89e7a
Child:
29:10a5cf37a875
--- a/LLComms.h	Mon Dec 17 15:09:44 2018 +0000
+++ b/LLComms.h	Mon Jan 28 21:24:48 2019 +0000
@@ -4,6 +4,8 @@
 #define LLCOMMS_H
 
 // STANDARD IMPORTS
+#include "math.h"
+#include <algorithm>
 // MBED IMPORTS
 #include "mbed.h"
 #include "mbed_events.h"
@@ -26,10 +28,10 @@
         EventQueue queue;
         Mutex mutChannel[N_CHANNELS];
         bool isDataReady[N_CHANNELS]; // Flag to indicate path data is ready for transmission to low level.
-        double demandPosition[N_CHANNELS];
-        double demandSpeed[N_CHANNELS];
+        double demandPosition_mm[N_CHANNELS];
+        double demandSpeed_mmps[N_CHANNELS];
         char chrErrorFlag[N_CHANNELS]; // 3 error bits from LL
-        double positionSensor_m[N_CHANNELS]; // The actual chamber lengths in meters given as the change in length relative to neutral (should always be >=0)
+        double positionSensor_mm[N_CHANNELS]; // The actual chamber lengths in meters given as the change in length relative to neutral (should always be >=0)
         double pressureSensor_bar[N_CHANNELS];  // The pressure in a given chamber in bar (1 bar  = 100,000 Pa)
         
         LLComms(); // Constructor
@@ -58,7 +60,10 @@
         
         int ThreadID[N_CHANNELS];
         
-        void formatMessage(short int type, int value);
+        unsigned int formatMessage(short int type, double dblValue, double dblMaxValue);
+        //bool CheckMessage(int msg, short int trueType);
+        bool CheckMessage(int msg);
+        bool PerformMasterSPI(SPI *spi, unsigned int outboundMsgs[], unsigned int inboundMsgsData[]);
         void SendReceiveData(int channel);
         void common_rise_handler(int channel);
         void common_fall_handler(int channel);