System Management code

Dependencies:   mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP

Fork of SystemManagement by Martin Deng

Files at this revision

API Documentation at this revision

Comitter:
martydd3
Date:
Tue Oct 07 22:42:35 2014 +0000
Parent:
2:baeb80c778f7
Child:
4:e31528929150
Commit message:
Added code for toggling DC_DC converter, turning off DC_DC on startup. Very simple starting code

Changed in this revision

SysMngmt.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/SysMngmt.cpp	Sun Oct 05 17:35:20 2014 +0000
+++ b/SysMngmt.cpp	Tue Oct 07 22:42:35 2014 +0000
@@ -346,9 +346,29 @@
     }
 }
 
+char dcCANId = 1;                   // first byte of CANData, last byte states whether to toggle on (1) or off (0)
+DigitalOut dcPin(p20);
+
+void toggleDC_DC(bool toggle){
+    static bool dc_on = false;
+    
+    //dcPin turns on DC_DC converter when 0, off when 1
+    
+    if(toggle && !dc_on){
+        dcPin = 0;
+        dc_on = true;
+    } else if(!toggle && dc_on){
+        dcPin = 1;
+        dc_on = false;   
+    }
+}
+
 int main() {
     CANMessage rx_msg;    
 
+    //turn off DC-DC converter on startup
+    toggleDC_DC(false);
+
     while(1)
     {
         if(rxBuffer.rxRead(rx_msg) && rx_msg.id == sysCANId){
@@ -363,6 +383,9 @@
                 
                 fan_Threads[pin_id] = new Thread(rampFans, rx_msg.data);
             }
+            if(rx_msg.data[0] == dcCANId){
+                toggleDC_DC((bool)rx_msg.data[7]);   
+            }
         }
     }
 }