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:
- 10:c8fccc083e1d
- Parent:
- 9:3292aeced59b
- Child:
- 11:72202d50f6b6
--- a/main.cpp Thu Nov 10 17:12:41 2016 +0000 +++ b/main.cpp Sat Nov 26 13:46:44 2016 +0000 @@ -129,22 +129,36 @@ { //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 rx_config [1][8]; + uint8_t write [1][6]; + uint8_t read [1][8]; + uint16_t cellcodes [1][12]; + + write[0][0]=0x02; + write[0][1]=0x00; + write[0][2]=0x00; + write[0][3]=0x00; + write[0][4]=0x00; + write[0][5]=0x00; //LTC6804_init(MD_FAST, DCP_DISABLED, CELL_CH_ALL, AUX_CH_VREF2); - while(-1) { + while(1) { wake_LTC6804();//ensures CMU's are in ready state and wakes it up from low power mode + LTC6804_setConfigReg(1,write); + wait(2); + wake_LTC6804(); wait_us(330); - //LTC6804_setConfigReg(1, tx_config); - //LTC6804_wrcfg(1,tx_config); + LTC6804_rdcfg(1,read); + LTC6804_init(MD_NORMAL,DCP_DISABLED,CELL_CH_ALL,AUX_CH_ALL); + LTC6804_acquireVoltageTx(); + wait_us(3000); //t.start(); - LTC6804_rdcfg(1,rx_config); + LTC6804_acquireAllVoltageRegRx(0, 1, cellcodes); //t.stop(); //cout << t.read() << endl; wait(3); - for (int i=0; i<8; i++) { - cout << (uint16_t)rx_config[0][i] << endl; + for (int i=0; i<12; i++) { + cout << (uint16_t)cellcodes[0][i] << endl; } } }