System Management code

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Revision:
38:8efacce315ae
Parent:
36:0afc0fc8f86b
Child:
39:ddf38df9699e
--- a/Libs/LatchMonitor/LatchMonitor.h	Thu Jan 22 07:59:48 2015 +0000
+++ b/Libs/LatchMonitor/LatchMonitor.h	Sat Feb 07 08:54:51 2015 +0000
@@ -4,26 +4,25 @@
 #include "mbed.h"
 
 enum LatchMon_Status_Bits {
-    okPinF=1,
-    faultPinF=2,
-    softwareF=4,
-    hardwareF=8,  
+    OK_FAULT        = 1<<0,     // Device OK pin is low
+    LATCHED_HARD    = 1<<1,     // Circuit is in the tripped state
+    LATCHED_SOFT    = 1<<2,     // Software-timer has expired and decided to tag the fault
+    HARD_FAULT      = 1<<3,     // The circuit should have latched open, but it did not
 };
 
-class LatchMonitor {
+class LatchMonitor
+{
 
 public:
     // Make this startup delay longer than the actual hardware circuit delay so that it can catch errors in the circuit
-    LatchMonitor(PinName _ok, PinName _fault, unsigned int startupDelay_ms);
-    /*
-        char update() returns status encoded in a char
-        bit0 = okPinFault - equals 1 when the OK pin from the monitored device is LOW indicating device fault
-        bit1 = faultPinFault - equals 1 when the sys. mgmt. latch circuit is faulted with startup timer in hardware
-        bit2 = softwareFault - equals 1 when the LatchMonitor fault occurs with startup timer in software
-        bit3 = hardwareFault - the circuit is supposed to signal fault on the hardware pin but its not doing so!
-    */
+    LatchMonitor(PinName _ok, PinName _fault);
+    void setup(float* startDelay);
+    void delayStart();
+    
     char update();
 private:
+    char lastStat;
+    float* startDelay;
     Timeout startup;
     void startupDelay();
     bool started;