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:
6:91b54ccbdf2d
Parent:
5:fc2503217ad4
Child:
7:fbe8e07fe96e
--- a/main.cpp	Wed Aug 31 10:58:19 2016 +0000
+++ b/main.cpp	Thu Sep 01 15:21:15 2016 +0000
@@ -5,16 +5,16 @@
 
 @brief
 This file contains the core code which runs on the BMU LPC1768 MBED. The primary function of the BMU is to obtain the relevant parameters of the battery pack which we are interested in monitoring and]
-placing it on the CAN Bus for the other nodes on the network to utilise. In the event that one of our parameters goes out of a predefined safe threshold (typically specified in the cell manufacturers 
+placing it on the CAN Bus for the other nodes on the network to utilise. In the event that one of our parameters goes out of a predefined safe threshold (typically specified in the cell manufacturers
 datasheet) we begin to limit the performance of the car so that it gets back to a region needed for safe operation (to be discussed further with telemetry).
 
-There are 3 primary communication protocols that the BMU utilises: CAN, SPI and I2C. 
+There are 3 primary communication protocols that the BMU utilises: CAN, SPI and I2C.
 
 -CAN is used to dump battery status information to the rest of the car
--I2C is used to commmunicate with the state of charge (SoC) board 
+-I2C is used to commmunicate with the state of charge (SoC) board
 -SPI is used to communicate with the CMUs which are individually addressed
 
-The mbed itself utilises conventional SPI and I2C which both get converted into differential signals to give isoSPI and dI2C to give 
+The mbed itself utilises conventional SPI and I2C which both get converted into differential signals to give isoSPI and dI2C to give
 greater resilience to EM noise reducing the chance of transmission errors.
 
 dI2C conversion is done by the PCA9615 IC
@@ -33,8 +33,8 @@
 
 Give state of BMS. If ok, go to run. Default into safe state and set error flag.
 
-LOOP 
-Start off displaying state 
+LOOP
+Start off displaying state
 Run SoC updating algorithm.
 Run current measurement.
 Perform voltage measurement.
@@ -46,7 +46,7 @@
 - Cell voltage
 - Cell temperatures
 - State of charge
-- Balancing status 
+- Balancing status
 - Error flag
 
 Will add helper function for communicating with both CMU (SPI) and SoC (I2C)
@@ -124,24 +124,30 @@
 //Define SoC ALCC digital in pin
 DigitalIn alcc(p20);
 
-int main () {
+int main ()
+{
     //spi.format(8,3); //All data transfer on LTC6804 occur in byte groups. LTC6820 set up such that POL=1 and PHA=3, this corresponds to mode 3 in mbed library. spi.frequency(spiBitrate);
-    //spi.frequency(spiBitrate);  
+    //spi.frequency(spiBitrate);
     uint8_t configReg [1][8];
-    //wake_LTC6804();//ensures CMU's are in ready state and wakes it up from low power mode
-    LTC6804_rdcfg(1, configReg);
-        
-    return 0;
-    }
     
+    wake_LTC6804();//ensures CMU's are in ready state and wakes it up from low power mode
+    LTC6804_init(MD_FAST, DCP_DISABLED, CELL_CH_ALL, AUX_CH_VREF2);
     
-    /*uint16_t vCells[numberOfCMUs][12];
-    
-    
-    LTC6804_init(MD_FILTERED, DCP_ENABLED, CELL_CH_ALL, AUX_CH_ALL);//set_adc
-    LTC6804_setConfigReg(
-    
-    LTC6804_acquireVoltageTx();//adcv
-    LTC6804_acquireAllVoltageRegRx(0, numberOfCMUs, vCells); //rdcv, 0 means read all cell voltages
-    */
-    
+    while(-1) {
+    LTC6804_rdcfg(1, configReg);
+    wait(0.5);
+    }
+    return 0;
+}
+
+
+/*uint16_t vCells[numberOfCMUs][12];
+
+
+LTC6804_init(MD_FILTERED, DCP_ENABLED, CELL_CH_ALL, AUX_CH_ALL);//set_adc
+LTC6804_setConfigReg(
+
+LTC6804_acquireVoltageTx();//adcv
+LTC6804_acquireAllVoltageRegRx(0, numberOfCMUs, vCells); //rdcv, 0 means read all cell voltages
+*/
+