Adds Balancing function (on the top of SPI_I2C_Parser.cpp) and changes main function adding a test case for balancing to show that it is working as intended.

Dependencies:   CUER_CAN mbed

Fork of BMS_BMUCore_cellvoltage_Mrinank by Mrinank Sharma

Revision:
13:499c1e2da85b
Parent:
12:f6ff8ddea5ab
--- a/main.cpp	Sun Nov 27 11:51:16 2016 +0000
+++ b/main.cpp	Thu Dec 01 15:15:13 2016 +0000
@@ -142,10 +142,12 @@
 
     LTC6804_init(MD_FAST, DCP_DISABLED, CELL_CH_ALL, AUX_CH_VREF2);
     //LTC6804_init(MD_NORMAL,DCP_DISABLED,CELL_CH_ALL,AUX_CH_ALL);
-
+    bool swap = 1;
+    wake_LTC6804();
+    LTC6804_wrcfg(1,write);
     while(1) {
         wake_LTC6804();//ensures CMU's are in ready state and wakes it up from low power mode
-        LTC6804_wrcfg(1,write);
+        //LTC6804_wrcfg(1,write);
         wait_us(330);
         LTC6804_rdcfg(1,read);
          wait_us(330);
@@ -163,6 +165,16 @@
             printf("Reading %d mV \r\n", (uint16_t)cellcodes[0][i]); 
         }
         printf("\r\n"); 
+        
+        //Test Balancing Code
+        
+        uint8_t states[12];
+        for(int i = 0; i < 12; i++)
+        {
+            states[i] = swap ^ (i % 2);   
+        }
+        LTC6804_balance(1,0,states);
+        swap = !swap;
     }
 }