mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
hal: made FuriHalI2cBusHandle static
This commit is contained in:
@@ -35,7 +35,7 @@ typedef struct {
|
||||
|
||||
static bq25896_regs_t bq25896_regs;
|
||||
|
||||
bool bq25896_init(FuriHalI2cBusHandle* handle) {
|
||||
bool bq25896_init(const FuriHalI2cBusHandle* handle) {
|
||||
bool result = true;
|
||||
|
||||
bq25896_regs.r14.REG_RST = 1;
|
||||
@@ -78,19 +78,19 @@ bool bq25896_init(FuriHalI2cBusHandle* handle) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void bq25896_set_boost_lim(FuriHalI2cBusHandle* handle, BoostLim boost_lim) {
|
||||
void bq25896_set_boost_lim(const FuriHalI2cBusHandle* handle, BoostLim boost_lim) {
|
||||
bq25896_regs.r0A.BOOST_LIM = boost_lim;
|
||||
furi_hal_i2c_write_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x0A, *(uint8_t*)&bq25896_regs.r0A, BQ25896_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
void bq25896_poweroff(FuriHalI2cBusHandle* handle) {
|
||||
void bq25896_poweroff(const FuriHalI2cBusHandle* handle) {
|
||||
bq25896_regs.r09.BATFET_DIS = 1;
|
||||
furi_hal_i2c_write_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x09, *(uint8_t*)&bq25896_regs.r09, BQ25896_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
ChrgStat bq25896_get_charge_status(FuriHalI2cBusHandle* handle) {
|
||||
ChrgStat bq25896_get_charge_status(const FuriHalI2cBusHandle* handle) {
|
||||
furi_hal_i2c_read_mem(
|
||||
handle,
|
||||
BQ25896_ADDRESS,
|
||||
@@ -103,52 +103,52 @@ ChrgStat bq25896_get_charge_status(FuriHalI2cBusHandle* handle) {
|
||||
return bq25896_regs.r0B.CHRG_STAT;
|
||||
}
|
||||
|
||||
bool bq25896_is_charging(FuriHalI2cBusHandle* handle) {
|
||||
bool bq25896_is_charging(const FuriHalI2cBusHandle* handle) {
|
||||
// Include precharge, fast charging, and charging termination done as "charging"
|
||||
return bq25896_get_charge_status(handle) != ChrgStatNo;
|
||||
}
|
||||
|
||||
bool bq25896_is_charging_done(FuriHalI2cBusHandle* handle) {
|
||||
bool bq25896_is_charging_done(const FuriHalI2cBusHandle* handle) {
|
||||
return bq25896_get_charge_status(handle) == ChrgStatDone;
|
||||
}
|
||||
|
||||
void bq25896_enable_charging(FuriHalI2cBusHandle* handle) {
|
||||
void bq25896_enable_charging(const FuriHalI2cBusHandle* handle) {
|
||||
bq25896_regs.r03.CHG_CONFIG = 1;
|
||||
furi_hal_i2c_write_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x03, *(uint8_t*)&bq25896_regs.r03, BQ25896_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
void bq25896_disable_charging(FuriHalI2cBusHandle* handle) {
|
||||
void bq25896_disable_charging(const FuriHalI2cBusHandle* handle) {
|
||||
bq25896_regs.r03.CHG_CONFIG = 0;
|
||||
furi_hal_i2c_write_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x03, *(uint8_t*)&bq25896_regs.r03, BQ25896_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
void bq25896_enable_otg(FuriHalI2cBusHandle* handle) {
|
||||
void bq25896_enable_otg(const FuriHalI2cBusHandle* handle) {
|
||||
bq25896_regs.r03.OTG_CONFIG = 1;
|
||||
furi_hal_i2c_write_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x03, *(uint8_t*)&bq25896_regs.r03, BQ25896_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
void bq25896_disable_otg(FuriHalI2cBusHandle* handle) {
|
||||
void bq25896_disable_otg(const FuriHalI2cBusHandle* handle) {
|
||||
bq25896_regs.r03.OTG_CONFIG = 0;
|
||||
furi_hal_i2c_write_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x03, *(uint8_t*)&bq25896_regs.r03, BQ25896_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
bool bq25896_is_otg_enabled(FuriHalI2cBusHandle* handle) {
|
||||
bool bq25896_is_otg_enabled(const FuriHalI2cBusHandle* handle) {
|
||||
furi_hal_i2c_read_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x03, (uint8_t*)&bq25896_regs.r03, BQ25896_I2C_TIMEOUT);
|
||||
return bq25896_regs.r03.OTG_CONFIG;
|
||||
}
|
||||
|
||||
uint16_t bq25896_get_vreg_voltage(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq25896_get_vreg_voltage(const FuriHalI2cBusHandle* handle) {
|
||||
furi_hal_i2c_read_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x06, (uint8_t*)&bq25896_regs.r06, BQ25896_I2C_TIMEOUT);
|
||||
return (uint16_t)bq25896_regs.r06.VREG * 16 + 3840;
|
||||
}
|
||||
|
||||
void bq25896_set_vreg_voltage(FuriHalI2cBusHandle* handle, uint16_t vreg_voltage) {
|
||||
void bq25896_set_vreg_voltage(const FuriHalI2cBusHandle* handle, uint16_t vreg_voltage) {
|
||||
if(vreg_voltage < 3840) {
|
||||
// Minimum valid value is 3840 mV
|
||||
vreg_voltage = 3840;
|
||||
@@ -166,13 +166,13 @@ void bq25896_set_vreg_voltage(FuriHalI2cBusHandle* handle, uint16_t vreg_voltage
|
||||
handle, BQ25896_ADDRESS, 0x06, *(uint8_t*)&bq25896_regs.r06, BQ25896_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
bool bq25896_check_otg_fault(FuriHalI2cBusHandle* handle) {
|
||||
bool bq25896_check_otg_fault(const FuriHalI2cBusHandle* handle) {
|
||||
furi_hal_i2c_read_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x0C, (uint8_t*)&bq25896_regs.r0C, BQ25896_I2C_TIMEOUT);
|
||||
return bq25896_regs.r0C.BOOST_FAULT;
|
||||
}
|
||||
|
||||
uint16_t bq25896_get_vbus_voltage(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq25896_get_vbus_voltage(const FuriHalI2cBusHandle* handle) {
|
||||
furi_hal_i2c_read_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x11, (uint8_t*)&bq25896_regs.r11, BQ25896_I2C_TIMEOUT);
|
||||
if(bq25896_regs.r11.VBUS_GD) {
|
||||
@@ -182,25 +182,25 @@ uint16_t bq25896_get_vbus_voltage(FuriHalI2cBusHandle* handle) {
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t bq25896_get_vsys_voltage(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq25896_get_vsys_voltage(const FuriHalI2cBusHandle* handle) {
|
||||
furi_hal_i2c_read_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x0F, (uint8_t*)&bq25896_regs.r0F, BQ25896_I2C_TIMEOUT);
|
||||
return (uint16_t)bq25896_regs.r0F.SYSV * 20 + 2304;
|
||||
}
|
||||
|
||||
uint16_t bq25896_get_vbat_voltage(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq25896_get_vbat_voltage(const FuriHalI2cBusHandle* handle) {
|
||||
furi_hal_i2c_read_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x0E, (uint8_t*)&bq25896_regs.r0E, BQ25896_I2C_TIMEOUT);
|
||||
return (uint16_t)bq25896_regs.r0E.BATV * 20 + 2304;
|
||||
}
|
||||
|
||||
uint16_t bq25896_get_vbat_current(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq25896_get_vbat_current(const FuriHalI2cBusHandle* handle) {
|
||||
furi_hal_i2c_read_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x12, (uint8_t*)&bq25896_regs.r12, BQ25896_I2C_TIMEOUT);
|
||||
return (uint16_t)bq25896_regs.r12.ICHGR * 50;
|
||||
}
|
||||
|
||||
uint32_t bq25896_get_ntc_mpct(FuriHalI2cBusHandle* handle) {
|
||||
uint32_t bq25896_get_ntc_mpct(const FuriHalI2cBusHandle* handle) {
|
||||
furi_hal_i2c_read_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x10, (uint8_t*)&bq25896_regs.r10, BQ25896_I2C_TIMEOUT);
|
||||
return (uint32_t)bq25896_regs.r10.TSPCT * 465 + 21000;
|
||||
|
||||
@@ -7,61 +7,61 @@
|
||||
#include <furi_hal_i2c.h>
|
||||
|
||||
/** Initialize Driver */
|
||||
bool bq25896_init(FuriHalI2cBusHandle* handle);
|
||||
bool bq25896_init(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Set boost lim*/
|
||||
void bq25896_set_boost_lim(FuriHalI2cBusHandle* handle, BoostLim boost_lim);
|
||||
void bq25896_set_boost_lim(const FuriHalI2cBusHandle* handle, BoostLim boost_lim);
|
||||
|
||||
/** Send device into shipping mode */
|
||||
void bq25896_poweroff(FuriHalI2cBusHandle* handle);
|
||||
void bq25896_poweroff(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get charging status */
|
||||
ChrgStat bq25896_get_charge_status(FuriHalI2cBusHandle* handle);
|
||||
ChrgStat bq25896_get_charge_status(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Is currently charging */
|
||||
bool bq25896_is_charging(FuriHalI2cBusHandle* handle);
|
||||
bool bq25896_is_charging(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Is charging completed while connected to charger */
|
||||
bool bq25896_is_charging_done(FuriHalI2cBusHandle* handle);
|
||||
bool bq25896_is_charging_done(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Enable charging */
|
||||
void bq25896_enable_charging(FuriHalI2cBusHandle* handle);
|
||||
void bq25896_enable_charging(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Disable charging */
|
||||
void bq25896_disable_charging(FuriHalI2cBusHandle* handle);
|
||||
void bq25896_disable_charging(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Enable otg */
|
||||
void bq25896_enable_otg(FuriHalI2cBusHandle* handle);
|
||||
void bq25896_enable_otg(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Disable otg */
|
||||
void bq25896_disable_otg(FuriHalI2cBusHandle* handle);
|
||||
void bq25896_disable_otg(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Is otg enabled */
|
||||
bool bq25896_is_otg_enabled(FuriHalI2cBusHandle* handle);
|
||||
bool bq25896_is_otg_enabled(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get VREG (charging limit) voltage in mV */
|
||||
uint16_t bq25896_get_vreg_voltage(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq25896_get_vreg_voltage(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Set VREG (charging limit) voltage in mV
|
||||
*
|
||||
* Valid range: 3840mV - 4208mV, in steps of 16mV
|
||||
*/
|
||||
void bq25896_set_vreg_voltage(FuriHalI2cBusHandle* handle, uint16_t vreg_voltage);
|
||||
void bq25896_set_vreg_voltage(const FuriHalI2cBusHandle* handle, uint16_t vreg_voltage);
|
||||
|
||||
/** Check OTG BOOST Fault status */
|
||||
bool bq25896_check_otg_fault(FuriHalI2cBusHandle* handle);
|
||||
bool bq25896_check_otg_fault(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get VBUS Voltage in mV */
|
||||
uint16_t bq25896_get_vbus_voltage(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq25896_get_vbus_voltage(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get VSYS Voltage in mV */
|
||||
uint16_t bq25896_get_vsys_voltage(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq25896_get_vsys_voltage(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get VBAT Voltage in mV */
|
||||
uint16_t bq25896_get_vbat_voltage(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq25896_get_vbat_voltage(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get VBAT current in mA */
|
||||
uint16_t bq25896_get_vbat_current(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq25896_get_vbat_current(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get NTC voltage in mpct of REGN */
|
||||
uint32_t bq25896_get_ntc_mpct(FuriHalI2cBusHandle* handle);
|
||||
uint32_t bq25896_get_ntc_mpct(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#endif
|
||||
|
||||
static inline bool bq27220_read_reg(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t address,
|
||||
uint8_t* buffer,
|
||||
size_t buffer_size) {
|
||||
@@ -52,7 +52,7 @@ static inline bool bq27220_read_reg(
|
||||
}
|
||||
|
||||
static inline bool bq27220_write(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t address,
|
||||
const uint8_t* buffer,
|
||||
size_t buffer_size) {
|
||||
@@ -60,11 +60,11 @@ static inline bool bq27220_write(
|
||||
handle, BQ27220_ADDRESS, address, buffer, buffer_size, BQ27220_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
static inline bool bq27220_control(FuriHalI2cBusHandle* handle, uint16_t control) {
|
||||
static inline bool bq27220_control(const FuriHalI2cBusHandle* handle, uint16_t control) {
|
||||
return bq27220_write(handle, CommandControl, (uint8_t*)&control, 2);
|
||||
}
|
||||
|
||||
static uint16_t bq27220_read_word(FuriHalI2cBusHandle* handle, uint8_t address) {
|
||||
static uint16_t bq27220_read_word(const FuriHalI2cBusHandle* handle, uint8_t address) {
|
||||
uint16_t buf = BQ27220_ERROR;
|
||||
|
||||
if(!bq27220_read_reg(handle, address, (uint8_t*)&buf, 2)) {
|
||||
@@ -83,7 +83,7 @@ static uint8_t bq27220_get_checksum(uint8_t* data, uint16_t len) {
|
||||
}
|
||||
|
||||
static bool bq27220_parameter_check(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint16_t address,
|
||||
uint32_t value,
|
||||
size_t size,
|
||||
@@ -163,7 +163,7 @@ static bool bq27220_parameter_check(
|
||||
}
|
||||
|
||||
static bool bq27220_data_memory_check(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
const BQ27220DMData* data_memory,
|
||||
bool update) {
|
||||
if(update) {
|
||||
@@ -268,7 +268,7 @@ static bool bq27220_data_memory_check(
|
||||
return result;
|
||||
}
|
||||
|
||||
bool bq27220_init(FuriHalI2cBusHandle* handle, const BQ27220DMData* data_memory) {
|
||||
bool bq27220_init(const FuriHalI2cBusHandle* handle, const BQ27220DMData* data_memory) {
|
||||
bool result = false;
|
||||
bool reset_and_provisioning_required = false;
|
||||
|
||||
@@ -365,7 +365,7 @@ bool bq27220_init(FuriHalI2cBusHandle* handle, const BQ27220DMData* data_memory)
|
||||
return result;
|
||||
}
|
||||
|
||||
bool bq27220_reset(FuriHalI2cBusHandle* handle) {
|
||||
bool bq27220_reset(const FuriHalI2cBusHandle* handle) {
|
||||
bool result = false;
|
||||
do {
|
||||
if(!bq27220_control(handle, Control_RESET)) {
|
||||
@@ -396,7 +396,7 @@ bool bq27220_reset(FuriHalI2cBusHandle* handle) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool bq27220_seal(FuriHalI2cBusHandle* handle) {
|
||||
bool bq27220_seal(const FuriHalI2cBusHandle* handle) {
|
||||
Bq27220OperationStatus operation_status = {0};
|
||||
bool result = false;
|
||||
do {
|
||||
@@ -431,7 +431,7 @@ bool bq27220_seal(FuriHalI2cBusHandle* handle) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool bq27220_unseal(FuriHalI2cBusHandle* handle) {
|
||||
bool bq27220_unseal(const FuriHalI2cBusHandle* handle) {
|
||||
Bq27220OperationStatus operation_status = {0};
|
||||
bool result = false;
|
||||
do {
|
||||
@@ -465,7 +465,7 @@ bool bq27220_unseal(FuriHalI2cBusHandle* handle) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool bq27220_full_access(FuriHalI2cBusHandle* handle) {
|
||||
bool bq27220_full_access(const FuriHalI2cBusHandle* handle) {
|
||||
bool result = false;
|
||||
|
||||
do {
|
||||
@@ -518,29 +518,35 @@ bool bq27220_full_access(FuriHalI2cBusHandle* handle) {
|
||||
return result;
|
||||
}
|
||||
|
||||
uint16_t bq27220_get_voltage(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq27220_get_voltage(const FuriHalI2cBusHandle* handle) {
|
||||
return bq27220_read_word(handle, CommandVoltage);
|
||||
}
|
||||
|
||||
int16_t bq27220_get_current(FuriHalI2cBusHandle* handle) {
|
||||
int16_t bq27220_get_current(const FuriHalI2cBusHandle* handle) {
|
||||
return bq27220_read_word(handle, CommandCurrent);
|
||||
}
|
||||
|
||||
bool bq27220_get_control_status(FuriHalI2cBusHandle* handle, Bq27220ControlStatus* control_status) {
|
||||
bool bq27220_get_control_status(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
Bq27220ControlStatus* control_status) {
|
||||
return bq27220_read_reg(handle, CommandControl, (uint8_t*)control_status, 2);
|
||||
}
|
||||
|
||||
bool bq27220_get_battery_status(FuriHalI2cBusHandle* handle, Bq27220BatteryStatus* battery_status) {
|
||||
bool bq27220_get_battery_status(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
Bq27220BatteryStatus* battery_status) {
|
||||
return bq27220_read_reg(handle, CommandBatteryStatus, (uint8_t*)battery_status, 2);
|
||||
}
|
||||
|
||||
bool bq27220_get_operation_status(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
Bq27220OperationStatus* operation_status) {
|
||||
return bq27220_read_reg(handle, CommandOperationStatus, (uint8_t*)operation_status, 2);
|
||||
}
|
||||
|
||||
bool bq27220_get_gauging_status(FuriHalI2cBusHandle* handle, Bq27220GaugingStatus* gauging_status) {
|
||||
bool bq27220_get_gauging_status(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
Bq27220GaugingStatus* gauging_status) {
|
||||
// Request gauging data to be loaded to MAC
|
||||
if(!bq27220_control(handle, Control_GAUGING_STATUS)) {
|
||||
FURI_LOG_E(TAG, "DM SelectSubclass for read failed");
|
||||
@@ -552,26 +558,26 @@ bool bq27220_get_gauging_status(FuriHalI2cBusHandle* handle, Bq27220GaugingStatu
|
||||
return bq27220_read_reg(handle, CommandMACData, (uint8_t*)gauging_status, 2);
|
||||
}
|
||||
|
||||
uint16_t bq27220_get_temperature(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq27220_get_temperature(const FuriHalI2cBusHandle* handle) {
|
||||
return bq27220_read_word(handle, CommandTemperature);
|
||||
}
|
||||
|
||||
uint16_t bq27220_get_full_charge_capacity(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq27220_get_full_charge_capacity(const FuriHalI2cBusHandle* handle) {
|
||||
return bq27220_read_word(handle, CommandFullChargeCapacity);
|
||||
}
|
||||
|
||||
uint16_t bq27220_get_design_capacity(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq27220_get_design_capacity(const FuriHalI2cBusHandle* handle) {
|
||||
return bq27220_read_word(handle, CommandDesignCapacity);
|
||||
}
|
||||
|
||||
uint16_t bq27220_get_remaining_capacity(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq27220_get_remaining_capacity(const FuriHalI2cBusHandle* handle) {
|
||||
return bq27220_read_word(handle, CommandRemainingCapacity);
|
||||
}
|
||||
|
||||
uint16_t bq27220_get_state_of_charge(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq27220_get_state_of_charge(const FuriHalI2cBusHandle* handle) {
|
||||
return bq27220_read_word(handle, CommandStateOfCharge);
|
||||
}
|
||||
|
||||
uint16_t bq27220_get_state_of_health(FuriHalI2cBusHandle* handle) {
|
||||
uint16_t bq27220_get_state_of_health(const FuriHalI2cBusHandle* handle) {
|
||||
return bq27220_read_word(handle, CommandStateOfHealth);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ typedef struct BQ27220DMData BQ27220DMData;
|
||||
*
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool bq27220_init(FuriHalI2cBusHandle* handle, const BQ27220DMData* data_memory);
|
||||
bool bq27220_init(const FuriHalI2cBusHandle* handle, const BQ27220DMData* data_memory);
|
||||
|
||||
/** Reset gauge
|
||||
*
|
||||
@@ -144,7 +144,7 @@ bool bq27220_init(FuriHalI2cBusHandle* handle, const BQ27220DMData* data_memory)
|
||||
*
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool bq27220_reset(FuriHalI2cBusHandle* handle);
|
||||
bool bq27220_reset(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Seal gauge access
|
||||
*
|
||||
@@ -152,7 +152,7 @@ bool bq27220_reset(FuriHalI2cBusHandle* handle);
|
||||
*
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool bq27220_seal(FuriHalI2cBusHandle* handle);
|
||||
bool bq27220_seal(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Unseal gauge access
|
||||
*
|
||||
@@ -160,7 +160,7 @@ bool bq27220_seal(FuriHalI2cBusHandle* handle);
|
||||
*
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool bq27220_unseal(FuriHalI2cBusHandle* handle);
|
||||
bool bq27220_unseal(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get full access
|
||||
*
|
||||
@@ -170,7 +170,7 @@ bool bq27220_unseal(FuriHalI2cBusHandle* handle);
|
||||
*
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool bq27220_full_access(FuriHalI2cBusHandle* handle);
|
||||
bool bq27220_full_access(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get battery voltage
|
||||
*
|
||||
@@ -178,7 +178,7 @@ bool bq27220_full_access(FuriHalI2cBusHandle* handle);
|
||||
*
|
||||
* @return voltage in mV or BQ27220_ERROR
|
||||
*/
|
||||
uint16_t bq27220_get_voltage(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq27220_get_voltage(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get current
|
||||
*
|
||||
@@ -186,7 +186,7 @@ uint16_t bq27220_get_voltage(FuriHalI2cBusHandle* handle);
|
||||
*
|
||||
* @return current in mA or BQ27220_ERROR
|
||||
*/
|
||||
int16_t bq27220_get_current(FuriHalI2cBusHandle* handle);
|
||||
int16_t bq27220_get_current(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get control status
|
||||
*
|
||||
@@ -195,7 +195,9 @@ int16_t bq27220_get_current(FuriHalI2cBusHandle* handle);
|
||||
*
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool bq27220_get_control_status(FuriHalI2cBusHandle* handle, Bq27220ControlStatus* control_status);
|
||||
bool bq27220_get_control_status(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
Bq27220ControlStatus* control_status);
|
||||
|
||||
/** Get battery status
|
||||
*
|
||||
@@ -204,7 +206,9 @@ bool bq27220_get_control_status(FuriHalI2cBusHandle* handle, Bq27220ControlStatu
|
||||
*
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool bq27220_get_battery_status(FuriHalI2cBusHandle* handle, Bq27220BatteryStatus* battery_status);
|
||||
bool bq27220_get_battery_status(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
Bq27220BatteryStatus* battery_status);
|
||||
|
||||
/** Get operation status
|
||||
*
|
||||
@@ -214,7 +218,7 @@ bool bq27220_get_battery_status(FuriHalI2cBusHandle* handle, Bq27220BatteryStatu
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool bq27220_get_operation_status(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
Bq27220OperationStatus* operation_status);
|
||||
|
||||
/** Get gauging status
|
||||
@@ -224,7 +228,9 @@ bool bq27220_get_operation_status(
|
||||
*
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool bq27220_get_gauging_status(FuriHalI2cBusHandle* handle, Bq27220GaugingStatus* gauging_status);
|
||||
bool bq27220_get_gauging_status(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
Bq27220GaugingStatus* gauging_status);
|
||||
|
||||
/** Get temperature
|
||||
*
|
||||
@@ -232,7 +238,7 @@ bool bq27220_get_gauging_status(FuriHalI2cBusHandle* handle, Bq27220GaugingStatu
|
||||
*
|
||||
* @return temperature in units of 0.1°K
|
||||
*/
|
||||
uint16_t bq27220_get_temperature(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq27220_get_temperature(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get compensated full charge capacity
|
||||
*
|
||||
@@ -240,7 +246,7 @@ uint16_t bq27220_get_temperature(FuriHalI2cBusHandle* handle);
|
||||
*
|
||||
* @return full charge capacity in mAh or BQ27220_ERROR
|
||||
*/
|
||||
uint16_t bq27220_get_full_charge_capacity(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq27220_get_full_charge_capacity(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get design capacity
|
||||
*
|
||||
@@ -248,7 +254,7 @@ uint16_t bq27220_get_full_charge_capacity(FuriHalI2cBusHandle* handle);
|
||||
*
|
||||
* @return design capacity in mAh or BQ27220_ERROR
|
||||
*/
|
||||
uint16_t bq27220_get_design_capacity(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq27220_get_design_capacity(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get remaining capacity
|
||||
*
|
||||
@@ -256,7 +262,7 @@ uint16_t bq27220_get_design_capacity(FuriHalI2cBusHandle* handle);
|
||||
*
|
||||
* @return remaining capacity in mAh or BQ27220_ERROR
|
||||
*/
|
||||
uint16_t bq27220_get_remaining_capacity(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq27220_get_remaining_capacity(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get predicted remaining battery capacity
|
||||
*
|
||||
@@ -264,7 +270,7 @@ uint16_t bq27220_get_remaining_capacity(FuriHalI2cBusHandle* handle);
|
||||
*
|
||||
* @return state of charge in percents or BQ27220_ERROR
|
||||
*/
|
||||
uint16_t bq27220_get_state_of_charge(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq27220_get_state_of_charge(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Get ratio of full charge capacity over design capacity
|
||||
*
|
||||
@@ -272,4 +278,4 @@ uint16_t bq27220_get_state_of_charge(FuriHalI2cBusHandle* handle);
|
||||
*
|
||||
* @return state of health in percents or BQ27220_ERROR
|
||||
*/
|
||||
uint16_t bq27220_get_state_of_health(FuriHalI2cBusHandle* handle);
|
||||
uint16_t bq27220_get_state_of_health(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
#include "lp5562_reg.h"
|
||||
#include <furi_hal.h>
|
||||
|
||||
void lp5562_reset(FuriHalI2cBusHandle* handle) {
|
||||
void lp5562_reset(const FuriHalI2cBusHandle* handle) {
|
||||
Reg0D_Reset reg = {.value = 0xFF};
|
||||
furi_hal_i2c_write_reg_8(handle, LP5562_ADDRESS, 0x0D, *(uint8_t*)®, LP5562_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
void lp5562_configure(FuriHalI2cBusHandle* handle) {
|
||||
void lp5562_configure(const FuriHalI2cBusHandle* handle) {
|
||||
Reg08_Config config = {.INT_CLK_EN = true, .PS_EN = true, .PWM_HF = true};
|
||||
furi_hal_i2c_write_reg_8(handle, LP5562_ADDRESS, 0x08, *(uint8_t*)&config, LP5562_I2C_TIMEOUT);
|
||||
|
||||
@@ -21,14 +21,17 @@ void lp5562_configure(FuriHalI2cBusHandle* handle) {
|
||||
furi_hal_i2c_write_reg_8(handle, LP5562_ADDRESS, 0x70, *(uint8_t*)&map, LP5562_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
void lp5562_enable(FuriHalI2cBusHandle* handle) {
|
||||
void lp5562_enable(const FuriHalI2cBusHandle* handle) {
|
||||
Reg00_Enable reg = {.CHIP_EN = true, .LOG_EN = true};
|
||||
furi_hal_i2c_write_reg_8(handle, LP5562_ADDRESS, 0x00, *(uint8_t*)®, LP5562_I2C_TIMEOUT);
|
||||
//>488μs delay is required after writing to 0x00 register, otherwise program engine will not work
|
||||
furi_delay_us(500);
|
||||
}
|
||||
|
||||
void lp5562_set_channel_current(FuriHalI2cBusHandle* handle, LP5562Channel channel, uint8_t value) {
|
||||
void lp5562_set_channel_current(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Channel channel,
|
||||
uint8_t value) {
|
||||
uint8_t reg_no;
|
||||
if(channel == LP5562ChannelRed) {
|
||||
reg_no = LP5562_CHANNEL_RED_CURRENT_REGISTER;
|
||||
@@ -44,7 +47,10 @@ void lp5562_set_channel_current(FuriHalI2cBusHandle* handle, LP5562Channel chann
|
||||
furi_hal_i2c_write_reg_8(handle, LP5562_ADDRESS, reg_no, value, LP5562_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
void lp5562_set_channel_value(FuriHalI2cBusHandle* handle, LP5562Channel channel, uint8_t value) {
|
||||
void lp5562_set_channel_value(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Channel channel,
|
||||
uint8_t value) {
|
||||
uint8_t reg_no;
|
||||
if(channel == LP5562ChannelRed) {
|
||||
reg_no = LP5562_CHANNEL_RED_VALUE_REGISTER;
|
||||
@@ -60,7 +66,7 @@ void lp5562_set_channel_value(FuriHalI2cBusHandle* handle, LP5562Channel channel
|
||||
furi_hal_i2c_write_reg_8(handle, LP5562_ADDRESS, reg_no, value, LP5562_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
uint8_t lp5562_get_channel_value(FuriHalI2cBusHandle* handle, LP5562Channel channel) {
|
||||
uint8_t lp5562_get_channel_value(const FuriHalI2cBusHandle* handle, LP5562Channel channel) {
|
||||
uint8_t reg_no;
|
||||
uint8_t value;
|
||||
if(channel == LP5562ChannelRed) {
|
||||
@@ -78,7 +84,10 @@ uint8_t lp5562_get_channel_value(FuriHalI2cBusHandle* handle, LP5562Channel chan
|
||||
return value;
|
||||
}
|
||||
|
||||
void lp5562_set_channel_src(FuriHalI2cBusHandle* handle, LP5562Channel channel, LP5562Engine src) {
|
||||
void lp5562_set_channel_src(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Channel channel,
|
||||
LP5562Engine src) {
|
||||
uint8_t reg_val = 0;
|
||||
uint8_t bit_offset = 0;
|
||||
|
||||
@@ -107,7 +116,7 @@ void lp5562_set_channel_src(FuriHalI2cBusHandle* handle, LP5562Channel channel,
|
||||
}
|
||||
|
||||
void lp5562_execute_program(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Engine eng,
|
||||
LP5562Channel ch,
|
||||
uint16_t* program) {
|
||||
@@ -155,7 +164,7 @@ void lp5562_execute_program(
|
||||
furi_hal_i2c_write_reg_8(handle, LP5562_ADDRESS, 0x00, enable_reg, LP5562_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
void lp5562_stop_program(FuriHalI2cBusHandle* handle, LP5562Engine eng) {
|
||||
void lp5562_stop_program(const FuriHalI2cBusHandle* handle, LP5562Engine eng) {
|
||||
if((eng < LP5562Engine1) || (eng > LP5562Engine3)) return;
|
||||
uint8_t reg_val = 0;
|
||||
uint8_t bit_offset = 0;
|
||||
@@ -169,7 +178,7 @@ void lp5562_stop_program(FuriHalI2cBusHandle* handle, LP5562Engine eng) {
|
||||
}
|
||||
|
||||
void lp5562_execute_ramp(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Engine eng,
|
||||
LP5562Channel ch,
|
||||
uint8_t val_start,
|
||||
@@ -213,7 +222,7 @@ void lp5562_execute_ramp(
|
||||
}
|
||||
|
||||
void lp5562_execute_blink(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Engine eng,
|
||||
LP5562Channel ch,
|
||||
uint16_t on_time,
|
||||
|
||||
@@ -20,39 +20,48 @@ typedef enum {
|
||||
} LP5562Engine;
|
||||
|
||||
/** Initialize Driver */
|
||||
void lp5562_reset(FuriHalI2cBusHandle* handle);
|
||||
void lp5562_reset(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Configure Driver */
|
||||
void lp5562_configure(FuriHalI2cBusHandle* handle);
|
||||
void lp5562_configure(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Enable Driver */
|
||||
void lp5562_enable(FuriHalI2cBusHandle* handle);
|
||||
void lp5562_enable(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Set channel current */
|
||||
void lp5562_set_channel_current(FuriHalI2cBusHandle* handle, LP5562Channel channel, uint8_t value);
|
||||
void lp5562_set_channel_current(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Channel channel,
|
||||
uint8_t value);
|
||||
|
||||
/** Set channel PWM value */
|
||||
void lp5562_set_channel_value(FuriHalI2cBusHandle* handle, LP5562Channel channel, uint8_t value);
|
||||
void lp5562_set_channel_value(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Channel channel,
|
||||
uint8_t value);
|
||||
|
||||
/** Get channel PWM value */
|
||||
uint8_t lp5562_get_channel_value(FuriHalI2cBusHandle* handle, LP5562Channel channel);
|
||||
uint8_t lp5562_get_channel_value(const FuriHalI2cBusHandle* handle, LP5562Channel channel);
|
||||
|
||||
/** Set channel source */
|
||||
void lp5562_set_channel_src(FuriHalI2cBusHandle* handle, LP5562Channel channel, LP5562Engine src);
|
||||
void lp5562_set_channel_src(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Channel channel,
|
||||
LP5562Engine src);
|
||||
|
||||
/** Execute program sequence */
|
||||
void lp5562_execute_program(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Engine eng,
|
||||
LP5562Channel ch,
|
||||
uint16_t* program);
|
||||
|
||||
/** Stop program sequence */
|
||||
void lp5562_stop_program(FuriHalI2cBusHandle* handle, LP5562Engine eng);
|
||||
void lp5562_stop_program(const FuriHalI2cBusHandle* handle, LP5562Engine eng);
|
||||
|
||||
/** Execute ramp program sequence */
|
||||
void lp5562_execute_ramp(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Engine eng,
|
||||
LP5562Channel ch,
|
||||
uint8_t val_start,
|
||||
@@ -61,7 +70,7 @@ void lp5562_execute_ramp(
|
||||
|
||||
/** Start blink program sequence */
|
||||
void lp5562_execute_blink(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
LP5562Engine eng,
|
||||
LP5562Channel ch,
|
||||
uint16_t on_time,
|
||||
|
||||
@@ -1287,23 +1287,23 @@ Function,+,furi_hal_hid_u2f_get_request,uint32_t,uint8_t*
|
||||
Function,+,furi_hal_hid_u2f_is_connected,_Bool,
|
||||
Function,+,furi_hal_hid_u2f_send_response,void,"uint8_t*, uint8_t"
|
||||
Function,+,furi_hal_hid_u2f_set_callback,void,"HidU2fCallback, void*"
|
||||
Function,+,furi_hal_i2c_acquire,void,FuriHalI2cBusHandle*
|
||||
Function,+,furi_hal_i2c_acquire,void,const FuriHalI2cBusHandle*
|
||||
Function,-,furi_hal_i2c_deinit_early,void,
|
||||
Function,-,furi_hal_i2c_init,void,
|
||||
Function,-,furi_hal_i2c_init_early,void,
|
||||
Function,+,furi_hal_i2c_is_device_ready,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_mem,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_reg_16,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint16_t*, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_reg_8,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t*, uint32_t"
|
||||
Function,+,furi_hal_i2c_release,void,FuriHalI2cBusHandle*
|
||||
Function,+,furi_hal_i2c_rx,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_rx_ext,_Bool,"FuriHalI2cBusHandle*, uint16_t, _Bool, uint8_t*, size_t, FuriHalI2cBegin, FuriHalI2cEnd, uint32_t"
|
||||
Function,+,furi_hal_i2c_trx,_Bool,"FuriHalI2cBusHandle*, uint8_t, const uint8_t*, size_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_tx,_Bool,"FuriHalI2cBusHandle*, uint8_t, const uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_tx_ext,_Bool,"FuriHalI2cBusHandle*, uint16_t, _Bool, const uint8_t*, size_t, FuriHalI2cBegin, FuriHalI2cEnd, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_mem,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, const uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_reg_16,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint16_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_reg_8,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_is_device_ready,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_mem,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_reg_16,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, uint16_t*, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_reg_8,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t*, uint32_t"
|
||||
Function,+,furi_hal_i2c_release,void,const FuriHalI2cBusHandle*
|
||||
Function,+,furi_hal_i2c_rx,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_rx_ext,_Bool,"const FuriHalI2cBusHandle*, uint16_t, _Bool, uint8_t*, size_t, FuriHalI2cBegin, FuriHalI2cEnd, uint32_t"
|
||||
Function,+,furi_hal_i2c_trx,_Bool,"const FuriHalI2cBusHandle*, uint8_t, const uint8_t*, size_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_tx,_Bool,"const FuriHalI2cBusHandle*, uint8_t, const uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_tx_ext,_Bool,"const FuriHalI2cBusHandle*, uint16_t, _Bool, const uint8_t*, size_t, FuriHalI2cBegin, FuriHalI2cEnd, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_mem,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, const uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_reg_16,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, uint16_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_reg_8,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t, uint32_t"
|
||||
Function,+,furi_hal_info_get,void,"PropertyValueCallback, char, void*"
|
||||
Function,+,furi_hal_info_get_api_version,void,"uint16_t*, uint16_t*"
|
||||
Function,-,furi_hal_init,void,
|
||||
@@ -2941,8 +2941,8 @@ Variable,+,compress_config_heatshrink_default,const CompressConfigHeatshrink,
|
||||
Variable,+,firmware_api_interface,const ElfApiInterface* const,
|
||||
Variable,+,furi_hal_i2c_bus_external,FuriHalI2cBus,
|
||||
Variable,+,furi_hal_i2c_bus_power,FuriHalI2cBus,
|
||||
Variable,+,furi_hal_i2c_handle_external,FuriHalI2cBusHandle,
|
||||
Variable,+,furi_hal_i2c_handle_power,FuriHalI2cBusHandle,
|
||||
Variable,+,furi_hal_i2c_handle_external,const FuriHalI2cBusHandle,
|
||||
Variable,+,furi_hal_i2c_handle_power,const FuriHalI2cBusHandle,
|
||||
Variable,+,furi_hal_spi_bus_d,FuriHalSpiBus,
|
||||
Variable,+,furi_hal_spi_bus_handle_display,const FuriHalSpiBusHandle,
|
||||
Variable,+,furi_hal_spi_bus_handle_external,const FuriHalSpiBusHandle,
|
||||
|
||||
|
@@ -1398,23 +1398,23 @@ Function,+,furi_hal_hid_u2f_get_request,uint32_t,uint8_t*
|
||||
Function,+,furi_hal_hid_u2f_is_connected,_Bool,
|
||||
Function,+,furi_hal_hid_u2f_send_response,void,"uint8_t*, uint8_t"
|
||||
Function,+,furi_hal_hid_u2f_set_callback,void,"HidU2fCallback, void*"
|
||||
Function,+,furi_hal_i2c_acquire,void,FuriHalI2cBusHandle*
|
||||
Function,+,furi_hal_i2c_acquire,void,const FuriHalI2cBusHandle*
|
||||
Function,-,furi_hal_i2c_deinit_early,void,
|
||||
Function,-,furi_hal_i2c_init,void,
|
||||
Function,-,furi_hal_i2c_init_early,void,
|
||||
Function,+,furi_hal_i2c_is_device_ready,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_mem,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_reg_16,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint16_t*, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_reg_8,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t*, uint32_t"
|
||||
Function,+,furi_hal_i2c_release,void,FuriHalI2cBusHandle*
|
||||
Function,+,furi_hal_i2c_rx,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_rx_ext,_Bool,"FuriHalI2cBusHandle*, uint16_t, _Bool, uint8_t*, size_t, FuriHalI2cBegin, FuriHalI2cEnd, uint32_t"
|
||||
Function,+,furi_hal_i2c_trx,_Bool,"FuriHalI2cBusHandle*, uint8_t, const uint8_t*, size_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_tx,_Bool,"FuriHalI2cBusHandle*, uint8_t, const uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_tx_ext,_Bool,"FuriHalI2cBusHandle*, uint16_t, _Bool, const uint8_t*, size_t, FuriHalI2cBegin, FuriHalI2cEnd, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_mem,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, const uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_reg_16,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint16_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_reg_8,_Bool,"FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_is_device_ready,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_mem,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_reg_16,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, uint16_t*, uint32_t"
|
||||
Function,+,furi_hal_i2c_read_reg_8,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t*, uint32_t"
|
||||
Function,+,furi_hal_i2c_release,void,const FuriHalI2cBusHandle*
|
||||
Function,+,furi_hal_i2c_rx,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_rx_ext,_Bool,"const FuriHalI2cBusHandle*, uint16_t, _Bool, uint8_t*, size_t, FuriHalI2cBegin, FuriHalI2cEnd, uint32_t"
|
||||
Function,+,furi_hal_i2c_trx,_Bool,"const FuriHalI2cBusHandle*, uint8_t, const uint8_t*, size_t, uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_tx,_Bool,"const FuriHalI2cBusHandle*, uint8_t, const uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_tx_ext,_Bool,"const FuriHalI2cBusHandle*, uint16_t, _Bool, const uint8_t*, size_t, FuriHalI2cBegin, FuriHalI2cEnd, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_mem,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, const uint8_t*, size_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_reg_16,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, uint16_t, uint32_t"
|
||||
Function,+,furi_hal_i2c_write_reg_8,_Bool,"const FuriHalI2cBusHandle*, uint8_t, uint8_t, uint8_t, uint32_t"
|
||||
Function,+,furi_hal_ibutton_emulate_set_next,void,uint32_t
|
||||
Function,+,furi_hal_ibutton_emulate_start,void,"uint32_t, FuriHalIbuttonEmulateCallback, void*"
|
||||
Function,+,furi_hal_ibutton_emulate_stop,void,
|
||||
@@ -3792,8 +3792,10 @@ Variable,+,compress_config_heatshrink_default,const CompressConfigHeatshrink,
|
||||
Variable,+,firmware_api_interface,const ElfApiInterface* const,
|
||||
Variable,+,furi_hal_i2c_bus_external,FuriHalI2cBus,
|
||||
Variable,+,furi_hal_i2c_bus_power,FuriHalI2cBus,
|
||||
Variable,+,furi_hal_i2c_handle_external,FuriHalI2cBusHandle,
|
||||
Variable,+,furi_hal_i2c_handle_power,FuriHalI2cBusHandle,
|
||||
Variable,+,furi_hal_i2c_handle_external,const FuriHalI2cBusHandle,
|
||||
Variable,+,furi_hal_i2c_handle_external,const FuriHalI2cBusHandle,
|
||||
Variable,+,furi_hal_i2c_handle_power,const FuriHalI2cBusHandle,
|
||||
Variable,+,furi_hal_i2c_handle_power,const FuriHalI2cBusHandle,
|
||||
Variable,+,furi_hal_spi_bus_d,FuriHalSpiBus,
|
||||
Variable,+,furi_hal_spi_bus_handle_display,const FuriHalSpiBusHandle,
|
||||
Variable,+,furi_hal_spi_bus_handle_external,const FuriHalSpiBusHandle,
|
||||
|
||||
|
@@ -22,7 +22,7 @@ void furi_hal_i2c_init(void) {
|
||||
FURI_LOG_I(TAG, "Init OK");
|
||||
}
|
||||
|
||||
void furi_hal_i2c_acquire(FuriHalI2cBusHandle* handle) {
|
||||
void furi_hal_i2c_acquire(const FuriHalI2cBusHandle* handle) {
|
||||
furi_hal_power_insomnia_enter();
|
||||
// Lock bus access
|
||||
handle->bus->callback(handle->bus, FuriHalI2cBusEventLock);
|
||||
@@ -36,7 +36,7 @@ void furi_hal_i2c_acquire(FuriHalI2cBusHandle* handle) {
|
||||
handle->callback(handle, FuriHalI2cBusHandleEventActivate);
|
||||
}
|
||||
|
||||
void furi_hal_i2c_release(FuriHalI2cBusHandle* handle) {
|
||||
void furi_hal_i2c_release(const FuriHalI2cBusHandle* handle) {
|
||||
// Ensure that current handle is our handle
|
||||
furi_check(handle->bus->current_handle == handle);
|
||||
// Deactivate handle
|
||||
@@ -196,7 +196,7 @@ static bool furi_hal_i2c_transaction(
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_rx_ext(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint16_t address,
|
||||
bool ten_bit,
|
||||
uint8_t* data,
|
||||
@@ -213,7 +213,7 @@ bool furi_hal_i2c_rx_ext(
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_tx_ext(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint16_t address,
|
||||
bool ten_bit,
|
||||
const uint8_t* data,
|
||||
@@ -230,7 +230,7 @@ bool furi_hal_i2c_tx_ext(
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_tx(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t address,
|
||||
const uint8_t* data,
|
||||
size_t size,
|
||||
@@ -242,7 +242,7 @@ bool furi_hal_i2c_tx(
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_rx(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t address,
|
||||
uint8_t* data,
|
||||
size_t size,
|
||||
@@ -254,7 +254,7 @@ bool furi_hal_i2c_rx(
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_trx(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t address,
|
||||
const uint8_t* tx_data,
|
||||
size_t tx_size,
|
||||
@@ -281,7 +281,10 @@ bool furi_hal_i2c_trx(
|
||||
timeout);
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_is_device_ready(FuriHalI2cBusHandle* handle, uint8_t i2c_addr, uint32_t timeout) {
|
||||
bool furi_hal_i2c_is_device_ready(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint32_t timeout) {
|
||||
furi_check(handle);
|
||||
furi_check(handle->bus->current_handle == handle);
|
||||
furi_check(timeout > 0);
|
||||
@@ -314,7 +317,7 @@ bool furi_hal_i2c_is_device_ready(FuriHalI2cBusHandle* handle, uint8_t i2c_addr,
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_read_reg_8(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t reg_addr,
|
||||
uint8_t* data,
|
||||
@@ -325,7 +328,7 @@ bool furi_hal_i2c_read_reg_8(
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_read_reg_16(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t reg_addr,
|
||||
uint16_t* data,
|
||||
@@ -340,7 +343,7 @@ bool furi_hal_i2c_read_reg_16(
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_read_mem(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t mem_addr,
|
||||
uint8_t* data,
|
||||
@@ -352,7 +355,7 @@ bool furi_hal_i2c_read_mem(
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_write_reg_8(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t reg_addr,
|
||||
uint8_t data,
|
||||
@@ -368,7 +371,7 @@ bool furi_hal_i2c_write_reg_8(
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_write_reg_16(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t reg_addr,
|
||||
uint16_t data,
|
||||
@@ -385,7 +388,7 @@ bool furi_hal_i2c_write_reg_16(
|
||||
}
|
||||
|
||||
bool furi_hal_i2c_write_mem(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t mem_addr,
|
||||
const uint8_t* data,
|
||||
|
||||
@@ -74,7 +74,7 @@ FuriHalI2cBus furi_hal_i2c_bus_external = {
|
||||
};
|
||||
|
||||
void furi_hal_i2c_bus_handle_power_event(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
FuriHalI2cBusHandleEvent event) {
|
||||
if(event == FuriHalI2cBusHandleEventActivate) {
|
||||
furi_hal_gpio_init_ex(
|
||||
@@ -120,13 +120,13 @@ void furi_hal_i2c_bus_handle_power_event(
|
||||
}
|
||||
}
|
||||
|
||||
FuriHalI2cBusHandle furi_hal_i2c_handle_power = {
|
||||
const FuriHalI2cBusHandle furi_hal_i2c_handle_power = {
|
||||
.bus = &furi_hal_i2c_bus_power,
|
||||
.callback = furi_hal_i2c_bus_handle_power_event,
|
||||
};
|
||||
|
||||
void furi_hal_i2c_bus_handle_external_event(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
FuriHalI2cBusHandleEvent event) {
|
||||
if(event == FuriHalI2cBusHandleEventActivate) {
|
||||
furi_hal_gpio_init_ex(
|
||||
@@ -160,7 +160,7 @@ void furi_hal_i2c_bus_handle_external_event(
|
||||
}
|
||||
}
|
||||
|
||||
FuriHalI2cBusHandle furi_hal_i2c_handle_external = {
|
||||
const FuriHalI2cBusHandle furi_hal_i2c_handle_external = {
|
||||
.bus = &furi_hal_i2c_bus_external,
|
||||
.callback = furi_hal_i2c_bus_handle_external_event,
|
||||
};
|
||||
|
||||
@@ -17,14 +17,14 @@ extern FuriHalI2cBus furi_hal_i2c_bus_external;
|
||||
* Pins: PA9(SCL) / PA10(SDA), float on release
|
||||
* Params: 400khz
|
||||
*/
|
||||
extern FuriHalI2cBusHandle furi_hal_i2c_handle_power;
|
||||
extern const FuriHalI2cBusHandle furi_hal_i2c_handle_power;
|
||||
|
||||
/** Handle for external i2c bus
|
||||
* Bus: furi_hal_i2c_bus_external
|
||||
* Pins: PC0(SCL) / PC1(SDA), float on release
|
||||
* Params: 100khz
|
||||
*/
|
||||
extern FuriHalI2cBusHandle furi_hal_i2c_handle_external;
|
||||
extern const FuriHalI2cBusHandle furi_hal_i2c_handle_external;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ typedef void (*FuriHalI2cBusEventCallback)(FuriHalI2cBus* bus, FuriHalI2cBusEven
|
||||
/** FuriHal i2c bus */
|
||||
struct FuriHalI2cBus {
|
||||
I2C_TypeDef* i2c;
|
||||
FuriHalI2cBusHandle* current_handle;
|
||||
const FuriHalI2cBusHandle* current_handle;
|
||||
FuriHalI2cBusEventCallback callback;
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef enum {
|
||||
|
||||
/** FuriHal i2c handle event callback */
|
||||
typedef void (*FuriHalI2cBusHandleEventCallback)(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
FuriHalI2cBusHandleEvent event);
|
||||
|
||||
/** FuriHal i2c handle */
|
||||
|
||||
@@ -55,14 +55,14 @@ void furi_hal_i2c_init(void);
|
||||
*
|
||||
* @param handle Pointer to FuriHalI2cBusHandle instance
|
||||
*/
|
||||
void furi_hal_i2c_acquire(FuriHalI2cBusHandle* handle);
|
||||
void furi_hal_i2c_acquire(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Release I2C bus handle
|
||||
*
|
||||
* @param handle Pointer to FuriHalI2cBusHandle instance acquired in
|
||||
* `furi_hal_i2c_acquire`
|
||||
*/
|
||||
void furi_hal_i2c_release(FuriHalI2cBusHandle* handle);
|
||||
void furi_hal_i2c_release(const FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Perform I2C TX transfer
|
||||
*
|
||||
@@ -75,7 +75,7 @@ void furi_hal_i2c_release(FuriHalI2cBusHandle* handle);
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_tx(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t address,
|
||||
const uint8_t* data,
|
||||
size_t size,
|
||||
@@ -96,7 +96,7 @@ bool furi_hal_i2c_tx(
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_tx_ext(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint16_t address,
|
||||
bool ten_bit,
|
||||
const uint8_t* data,
|
||||
@@ -116,7 +116,7 @@ bool furi_hal_i2c_tx_ext(
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_rx(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t address,
|
||||
uint8_t* data,
|
||||
size_t size,
|
||||
@@ -136,7 +136,7 @@ bool furi_hal_i2c_rx(
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_rx_ext(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint16_t address,
|
||||
bool ten_bit,
|
||||
uint8_t* data,
|
||||
@@ -158,7 +158,7 @@ bool furi_hal_i2c_rx_ext(
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_trx(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t address,
|
||||
const uint8_t* tx_data,
|
||||
size_t tx_size,
|
||||
@@ -174,7 +174,10 @@ bool furi_hal_i2c_trx(
|
||||
*
|
||||
* @return true if device present and is ready, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_is_device_ready(FuriHalI2cBusHandle* handle, uint8_t i2c_addr, uint32_t timeout);
|
||||
bool furi_hal_i2c_is_device_ready(
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint32_t timeout);
|
||||
|
||||
/** Perform I2C device register read (8-bit)
|
||||
*
|
||||
@@ -187,7 +190,7 @@ bool furi_hal_i2c_is_device_ready(FuriHalI2cBusHandle* handle, uint8_t i2c_addr,
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_read_reg_8(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t reg_addr,
|
||||
uint8_t* data,
|
||||
@@ -204,7 +207,7 @@ bool furi_hal_i2c_read_reg_8(
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_read_reg_16(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t reg_addr,
|
||||
uint16_t* data,
|
||||
@@ -222,7 +225,7 @@ bool furi_hal_i2c_read_reg_16(
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_read_mem(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t mem_addr,
|
||||
uint8_t* data,
|
||||
@@ -240,7 +243,7 @@ bool furi_hal_i2c_read_mem(
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_write_reg_8(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t reg_addr,
|
||||
uint8_t data,
|
||||
@@ -257,7 +260,7 @@ bool furi_hal_i2c_write_reg_8(
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_write_reg_16(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t reg_addr,
|
||||
uint16_t data,
|
||||
@@ -275,7 +278,7 @@ bool furi_hal_i2c_write_reg_16(
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_write_mem(
|
||||
FuriHalI2cBusHandle* handle,
|
||||
const FuriHalI2cBusHandle* handle,
|
||||
uint8_t i2c_addr,
|
||||
uint8_t mem_addr,
|
||||
const uint8_t* data,
|
||||
|
||||
Reference in New Issue
Block a user