Drivers: skip initialization if bq27220 is unresponsive (#435)
This commit is contained in:
parent
724b738048
commit
eb82748d50
@ -64,10 +64,12 @@ bool bq27220_set_parameter_u16(uint16_t address, uint16_t value) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void bq27220_init(const ParamCEDV* cedv) {
|
||||
bool bq27220_init(const ParamCEDV* cedv) {
|
||||
uint32_t timeout = 100;
|
||||
OperationStatus status = {};
|
||||
bq27220_control(Control_ENTER_CFG_UPDATE);
|
||||
if(!bq27220_control(Control_ENTER_CFG_UPDATE)) {
|
||||
return false;
|
||||
};
|
||||
while((status.CFGUPDATE != 1) && (timeout-- > 0)) {
|
||||
bq27220_get_operation_status(&status);
|
||||
}
|
||||
@ -111,6 +113,7 @@ void bq27220_init(const ParamCEDV* cedv) {
|
||||
delay_us(15000);
|
||||
|
||||
bq27220_control(Control_EXIT_CFG_UPDATE);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t bq27220_get_voltage() {
|
||||
|
@ -66,8 +66,10 @@ typedef struct {
|
||||
uint16_t DOD100;
|
||||
} ParamCEDV;
|
||||
|
||||
/** Initialize Driver */
|
||||
void bq27220_init(const ParamCEDV* cedv);
|
||||
/** Initialize Driver
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool bq27220_init(const ParamCEDV* cedv);
|
||||
|
||||
/** Get battery voltage in mV or error */
|
||||
uint16_t bq27220_get_voltage();
|
||||
|
Loading…
Reference in New Issue
Block a user