//////////read command register///////////// i2cSendStart(); i2cWaitForComplete(); i2cSendByte(0xaa); //writes to BQ i2cWaitForComplete(); i2cSendByte(0x00); //control register i2cWaitForComplete(); i2cSendStop(); i2cSendStart(); i2cWaitForComplete(); i2cSendByte(0xab); //reads from BQ i2cWaitForComplete(); i2cReceiveByte(TRUE); i2cWaitForComplete(); xm = i2cGetReceivedByte(); //high byte i2cWaitForComplete(); i2cReceiveByte(TRUE); i2cWaitForComplete(); xl = i2cGetReceivedByte(); //high byte i2cWaitForComplete(); i2cReceiveByte(TRUE); i2cSendStop(); i2cSendStart(); xo = xl|(xm << 8); return xo; } void read_percent(void) { //0xaa write, 0xab read uint8_t xm, xl; //uint8_t xmh, xml, xlh, xll; //long xo; i2cSendStart(); i2cWaitForComplete(); i2cSendByte(0xaa); //writes to BQ i2cWaitForComplete(); i2cSendByte(0x2c); //SOC register 0.2c for bq27510 i2cWaitForComplete(); i2cSendStop(); i2cSendStart(); i2cWaitForComplete(); i2cSendByte(0xab); //read from BQ i2cWaitForComplete(); i2cReceiveByte(TRUE); i2cWaitForComplete(); xm = i2cGetReceivedByte(); //high byte i2cWaitForComplete(); i2cReceiveByte(TRUE); i2cWaitForComplete(); xl = i2cGetReceivedByte(); //high byte i2cWaitForComplete(); i2cReceiveByte(TRUE); i2cSendStop(); i2cSendStart();