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.
Fork of BMS_BMUCore_cellvoltage_Mrinank by
Diff: main.cpp
- Revision:
- 8:2506aef0c8db
- Parent:
- 7:fbe8e07fe96e
- Child:
- 9:3292aeced59b
--- a/main.cpp Mon Sep 05 19:50:47 2016 +0000 +++ b/main.cpp Tue Nov 08 17:02:55 2016 +0000 @@ -123,20 +123,34 @@ //Define SoC ALCC digital in pin DigitalIn alcc(p20); +Timer t; 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); - uint8_t configReg [1][8]; - - - LTC6804_init(MD_FAST, DCP_DISABLED, CELL_CH_ALL, AUX_CH_VREF2); - + uint8_t rx_config [1][8]; + uint8_t tx_config [1][6]; + + tx_config[0][0]=0x04; + for (int i=0; i<5; i++) { + tx_config[0][i+1]=0x00; + } + + //LTC6804_init(MD_FAST, DCP_DISABLED, CELL_CH_ALL, AUX_CH_VREF2); + while(-1) { - wake_LTC6804();//ensures CMU's are in ready state and wakes it up from low power mode - LTC6804_rdcfg(1, configReg); - wait(5); + wake_LTC6804();//ensures CMU's are in ready state and wakes it up from low power mode + //LTC6804_setConfigReg(1, tx_config); + LTC6804_wrcfg(1,tx_config); + //t.start(); + LTC6804_rdcfg(1,rx_config); + //t.stop(); + //cout << t.read() << endl; + //wait(3); + for (int i=0; i<8; i++) { + cout << (uint16_t)rx_config[0][i] << endl; + } } }