[FL-1911] FuriHal: i2c refactoring (#847)

* Project: fix release build, replace asserts with checks.
* FuriHal: i2c refactoring, new bus access model, flexible bus gpio configuration.
* FuriHal: set i2c pins to high on detach.
* FuriHal: more i2c bus events, put bus under reset when not used, move bus enable/disable routine to bus handler.
* FuriHal: fix i2c deadlock in power api, add external i2c handle.
This commit is contained in:
あく
2021-11-28 21:28:19 +03:00
committed by GitHub
parent 7c0943e736
commit cf591ef7eb
45 changed files with 1685 additions and 781 deletions

View File

@@ -2,6 +2,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <furi-hal-i2c.h>
#define BQ27220_ERROR 0x0
#define BQ27220_SUCCESS 0x1
@@ -95,36 +96,36 @@ typedef struct {
/** Initialize Driver
* @return true on success, false otherwise
*/
bool bq27220_init(const ParamCEDV* cedv);
bool bq27220_init(FuriHalI2cBusHandle* handle, const ParamCEDV* cedv);
/** Get battery voltage in mV or error */
uint16_t bq27220_get_voltage();
uint16_t bq27220_get_voltage(FuriHalI2cBusHandle* handle);
/** Get current in mA or error*/
int16_t bq27220_get_current();
int16_t bq27220_get_current(FuriHalI2cBusHandle* handle);
/** Get battery status */
uint8_t bq27220_get_battery_status(BatteryStatus* battery_status);
uint8_t bq27220_get_battery_status(FuriHalI2cBusHandle* handle, BatteryStatus* battery_status);
/** Get operation status */
uint8_t bq27220_get_operation_status(OperationStatus* operation_status);
uint8_t bq27220_get_operation_status(FuriHalI2cBusHandle* handle, OperationStatus* operation_status);
/** Get temperature in units of 0.1°K */
uint16_t bq27220_get_temperature();
uint16_t bq27220_get_temperature(FuriHalI2cBusHandle* handle);
/** Get compensated full charge capacity in in mAh */
uint16_t bq27220_get_full_charge_capacity();
uint16_t bq27220_get_full_charge_capacity(FuriHalI2cBusHandle* handle);
/** Get design capacity in mAh */
uint16_t bq27220_get_design_capacity();
uint16_t bq27220_get_design_capacity(FuriHalI2cBusHandle* handle);
/** Get remaining capacity in in mAh */
uint16_t bq27220_get_remaining_capacity();
uint16_t bq27220_get_remaining_capacity(FuriHalI2cBusHandle* handle);
/** Get predicted remaining battery capacity in percents */
uint16_t bq27220_get_state_of_charge();
uint16_t bq27220_get_state_of_charge(FuriHalI2cBusHandle* handle);
/** Get ratio of full charge capacity over design capacity in percents */
uint16_t bq27220_get_state_of_health();
uint16_t bq27220_get_state_of_health(FuriHalI2cBusHandle* handle);
void bq27220_change_design_capacity(uint16_t capacity);
void bq27220_change_design_capacity(FuriHalI2cBusHandle* handle, uint16_t capacity);