Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
Diff: DC_DC/DC_DC.cpp
- Revision:
- 6:6a04210a3f4f
- Child:
- 10:db13782f05d9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/DC_DC/DC_DC.cpp Fri Oct 10 20:24:22 2014 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"
+#include "DC_DC.h"
+
+DigitalOut dc_pin(p20);
+FanPump *fanPump;
+CANBuffer *tx_DC_Buffer;
+bool status;
+
+DC::DC(FanPump *fp, CANBuffer *can){
+ status = false;
+ dc_pin = !status;
+ tx_DC_Buffer = can;
+ fanPump = fp;
+}
+
+bool DC::is_on(){
+ return status;
+}
+
+void DC::set(bool s){
+ status = s;
+ if(!status){
+ fanPump->shutdown_all();
+ }
+
+ dc_pin = !status;
+}
+
+void update(const void *arg){
+ char data[4] = {0};
+ while(1){
+ data[0] = status;
+ CANMessage txMessage(TX_DC_DC_ID, data, 4);
+ CANMessage msg(1);
+ tx_DC_Buffer->txWrite(msg);
+
+ Thread::wait(100); //10 Hz update
+ }
+}
+
+void DC::start_update(){
+ Thread update_thread(update);
+}
\ No newline at end of file
