all bms comunicating with nucleo board and balancing

Dependencies:   CANnucleo mbed

Fork of Can_sniffer_BMS_GER by Joao Vieira

Revision:
47:278a5a4326cc
Parent:
46:8fc10f7a8739
--- a/main.cpp	Thu Dec 01 12:55:27 2016 +0000
+++ b/main.cpp	Wed Mar 01 18:00:02 2017 +0000
@@ -232,12 +232,20 @@
     led = controller_key_switch;
 }
 
+void ialarm() //desligamento dos contactores devido a IMD
+{
+    controller_key_switch = 0;
+    led = controller_key_switch;
+}
+
 
 Ticker refresher;
 Ticker printer;
 Ticker printer2;
 InterruptIn button(PC_13);
 
+InterruptIn imdok(PA_9);
+
 typedef union can_union {
     int i[2];
     char bytes[8];
@@ -245,7 +253,7 @@
 } data;
 
 //bool to_charge_or_not_to_charge=true;           // false = discharge
-bool charging = true;
+bool charging = 1;
 
 uint8_t motostate=0;
 
@@ -253,7 +261,8 @@
     can.frequency(1000000);                     // set bit rate to 1Mbps
     can.attach(&onMsgReceived);                 // attach 'CAN receive-complete' interrupt handler
     refresher.attach(&refresh, 5);                 // turn on or off
-    button.rise(&flip);    
+  button.rise(&flip); 
+  imdok.fall(&ialarm);    
         printer.attach(&cvprint, 20);                 // turn on o
         printer2.attach(&ctprint, 50);                 // turn on o