Penn Electric Racing / Mbed 2 deprecated SystemManagement

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Revision:
38:8efacce315ae
Parent:
36:0afc0fc8f86b
diff -r 2207b58b9a7f -r 8efacce315ae Libs/DC_DC/DC_DC.h
--- a/Libs/DC_DC/DC_DC.h	Thu Jan 22 07:59:48 2015 +0000
+++ b/Libs/DC_DC/DC_DC.h	Sat Feb 07 08:54:51 2015 +0000
@@ -5,26 +5,26 @@
 #include "FanPump.h"
 
 enum Channel_T {
-    FAN1=0,
-    FAN2,
-    PUMP1,
-    PUMP2,  
+    FAN1            = 0,
+    FAN2            = 1,
+    PUMP1           = 2,
+    PUMP2           = 3,  
 };
+
 enum Status_Bits_T {  
-    ConvOn=1,
-    SetOn=2,
-    PowerUp=4,
-    PowerDown=8,
-    OverCurrent=16,
-    SensorFault=32,
-    FailStart=64,
-    FailStop=128,
+    CONV_ON         = 1<<0,
+    SET_ON          = 1<<1,
+    POWER_UP        = 1<<2,
+    POWER_DOWN      = 1<<3,
+    OVER_CURRENT    = 1<<4,
+    SENSOR_FAULT    = 1<<5,
 };
-const int DC_DC_FILTER_TAPS = 50;
 
 class DC_DC{
 public:
-    DC_DC(PinName _dcdcPin, PinName _dcdcCurrent, PinName _fan1, PinName _fan2, PinName _pump1, PinName _pump2, float period, float slew);
+    DC_DC(PinName _dcdcPin, PinName _dcdcCurrent, PinName _fan1, PinName _fan2, PinName _pump1, PinName _pump2, float period, float slew, unsigned int size=50);
+    void setup(float* onThreshold, float* overCurrent, float* startDelay, float* stopDelay);
+    bool size(unsigned int size);
     float getCurrent() { return current; }
     void set(bool on); 
     void setPwm(enum Channel_T chan, float duty);
@@ -37,26 +37,25 @@
         bit3 - 1 = DC-DC Power-down, its use is currently blocked until ready
         bit4 - 1 = DC-DC over current (drawing more current than allowed according to sensor)
         bit5 - 1 = DC-DC current sensor out of range (broken)
-        bit6 - 1 = DC-DC failed to start
-        bit7 - 1 = DC-DC failed to stop
     */
     char getStatus() { return status; }
     bool hasCritError() { return critError; }         // An error exists according to status above
     void sample();                   // Attach this function in a 10ms RTOS timer
 
 private:
+    
     Timer startTimer;
     Timer stopTimer;
-    volatile bool starting;
-    volatile bool stopping;
     volatile bool isControlPinOn;
     DigitalOut dcdcControl;
     AnalogIn dcdcCurrent;
-    volatile float currentOffset;
-    volatile float filterBuff[DC_DC_FILTER_TAPS];
-    volatile int buffTracker;
+    
+    float currentOffset;
+    float* filterBuff;
+    int buffTracker;
+    unsigned int _size;
+    
     void updateCurrent();
-
     volatile float current;
     volatile char status;
     volatile bool critError;
@@ -65,6 +64,11 @@
     FanPump fan2;
     FanPump pump1;
     FanPump pump2;
+    
+    float* onThreshold;
+    float* overCurrent;
+    float* startDelay;
+    float* stopDelay;
 };
 
 #endif
\ No newline at end of file