new CanControl

Files at this revision

API Documentation at this revision

Comitter:
kwasymodo
Date:
Sun May 21 22:00:17 2017 +0000
Parent:
1:25258579a80d
Commit message:
changed debug

Changed in this revision

CanControl.cpp Show annotated file Show diff for this revision Revisions of this file
CanControl.h Show annotated file Show diff for this revision Revisions of this file
diff -r 25258579a80d -r d7776fa70ef5 CanControl.cpp
--- a/CanControl.cpp	Fri May 12 20:30:34 2017 +0000
+++ b/CanControl.cpp	Sun May 21 22:00:17 2017 +0000
@@ -1,10 +1,10 @@
-#include "PowerControl.h"
+#include "CanControl.h"
 
 extern RawSerial pc;
 extern CAN can;
 
 CanControl::CanControl(PinName buckCan):
-    _buckCan(buckCan), _canEnable(CAN_ENABLE)
+    _buckCan(buckCan), _canEnable(CAN_ENABLE), _ledRelay(LED2)
 {
     enabled = false;
     repeat.attach(this, &CanControl::relay, 1.0);
@@ -19,6 +19,7 @@
     wait_ms(100);
     _canEnable = 0;
     _buckCan = 0;
+    _ledRelay = 0;
     return true;
 }
 
@@ -29,6 +30,7 @@
     enabled = true;
     _buckCan = 1;
     _canEnable = 1;
+    _ledRelay = 1;
     wait_ms(100);
     can.write(CANMessage(BMSCANADDRESS, "1"));
     return true;
@@ -37,7 +39,7 @@
 void CanControl::relay(void){
     if(enabled){
 #ifdef DEBUG
-    pc.printf("CANMessage sent: BMSCANADDRESS, \"1\"\r\n");
+        pc.printf("CANMessage sent: BMSCANADDRESS, \"1\"\r\n");
 #endif
         can.write(CANMessage(BMSCANADDRESS, "1"));
     }
diff -r 25258579a80d -r d7776fa70ef5 CanControl.h
--- a/CanControl.h	Fri May 12 20:30:34 2017 +0000
+++ b/CanControl.h	Sun May 21 22:00:17 2017 +0000
@@ -1,7 +1,12 @@
 #ifndef CANCONTROL_H
 #define CANCONTROL_H
 
+// uncomment to send debug information
+#define DEBUG
+
 #include "mbed.h"
+// include own libraries
+#include "pinout.h"
 
 #define BMSCANADDRESS 0x033
 
@@ -38,6 +43,7 @@
     
     DigitalOut _buckCan;
     DigitalOut _canEnable;
+    DigitalOut _ledRelay;
     Ticker repeat;
     bool enabled;    
 };