Furi_Power: fix furi_hal_power_enable_otg (#2842)
* Furi_Power: fix furi_hal_power_enable_otg * SubGhz: fix error output connected USB * Furi_Hal: fix target F18 * Fix api_symbols.csv version for F7 Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
parent
f3ae09cc16
commit
906cca8f24
@ -8,11 +8,17 @@
|
||||
|
||||
static void subghz_txrx_radio_device_power_on(SubGhzTxRx* instance) {
|
||||
UNUSED(instance);
|
||||
uint8_t attempts = 0;
|
||||
while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
|
||||
furi_hal_power_enable_otg();
|
||||
//CC1101 power-up time
|
||||
furi_delay_ms(10);
|
||||
uint8_t attempts = 5;
|
||||
while(--attempts > 0) {
|
||||
if(furi_hal_power_enable_otg()) break;
|
||||
}
|
||||
if(attempts == 0) {
|
||||
if(furi_hal_power_get_usb_voltage() < 4.5f) {
|
||||
FURI_LOG_E(
|
||||
TAG,
|
||||
"Error power otg enable. BQ2589 check otg fault = %d",
|
||||
furi_hal_power_check_otg_fault() ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,32.0,,
|
||||
Version,+,33.0,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@ -1030,12 +1030,13 @@ Function,+,furi_hal_mpu_protect_no_access,void,"FuriHalMpuRegion, uint32_t, Furi
|
||||
Function,+,furi_hal_mpu_protect_read_only,void,"FuriHalMpuRegion, uint32_t, FuriHalMPURegionSize"
|
||||
Function,-,furi_hal_os_init,void,
|
||||
Function,+,furi_hal_os_tick,void,
|
||||
Function,+,furi_hal_power_check_otg_fault,_Bool,
|
||||
Function,+,furi_hal_power_check_otg_status,void,
|
||||
Function,+,furi_hal_power_debug_get,void,"PropertyValueCallback, void*"
|
||||
Function,+,furi_hal_power_disable_external_3_3v,void,
|
||||
Function,+,furi_hal_power_disable_otg,void,
|
||||
Function,+,furi_hal_power_enable_external_3_3v,void,
|
||||
Function,+,furi_hal_power_enable_otg,void,
|
||||
Function,+,furi_hal_power_enable_otg,_Bool,
|
||||
Function,+,furi_hal_power_gauge_is_ok,_Bool,
|
||||
Function,+,furi_hal_power_get_bat_health_pct,uint8_t,
|
||||
Function,+,furi_hal_power_get_battery_charge_voltage_limit,float,
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,32.0,,
|
||||
Version,+,33.0,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@ -1235,12 +1235,13 @@ Function,+,furi_hal_nfc_tx_rx,_Bool,"FuriHalNfcTxRxContext*, uint16_t"
|
||||
Function,+,furi_hal_nfc_tx_rx_full,_Bool,FuriHalNfcTxRxContext*
|
||||
Function,-,furi_hal_os_init,void,
|
||||
Function,+,furi_hal_os_tick,void,
|
||||
Function,+,furi_hal_power_check_otg_fault,_Bool,
|
||||
Function,+,furi_hal_power_check_otg_status,void,
|
||||
Function,+,furi_hal_power_debug_get,void,"PropertyValueCallback, void*"
|
||||
Function,+,furi_hal_power_disable_external_3_3v,void,
|
||||
Function,+,furi_hal_power_disable_otg,void,
|
||||
Function,+,furi_hal_power_enable_external_3_3v,void,
|
||||
Function,+,furi_hal_power_enable_otg,void,
|
||||
Function,+,furi_hal_power_enable_otg,_Bool,
|
||||
Function,+,furi_hal_power_gauge_is_ok,_Bool,
|
||||
Function,+,furi_hal_power_get_bat_health_pct,uint8_t,
|
||||
Function,+,furi_hal_power_get_battery_charge_voltage_limit,float,
|
||||
|
||||
|
@ -284,10 +284,15 @@ void furi_hal_power_reset() {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void furi_hal_power_enable_otg() {
|
||||
bool furi_hal_power_enable_otg() {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bq25896_set_boost_lim(&furi_hal_i2c_handle_power, BoostLim_2150);
|
||||
bq25896_enable_otg(&furi_hal_i2c_handle_power);
|
||||
furi_delay_ms(30);
|
||||
bool ret = bq25896_is_otg_enabled(&furi_hal_i2c_handle_power);
|
||||
bq25896_set_boost_lim(&furi_hal_i2c_handle_power, BoostLim_1400);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void furi_hal_power_disable_otg() {
|
||||
@ -317,6 +322,13 @@ void furi_hal_power_set_battery_charge_voltage_limit(float voltage) {
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
}
|
||||
|
||||
bool furi_hal_power_check_otg_fault() {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
bool ret = bq25896_check_otg_fault(&furi_hal_i2c_handle_power);
|
||||
furi_hal_i2c_release(&furi_hal_i2c_handle_power);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void furi_hal_power_check_otg_status() {
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
if(bq25896_check_otg_fault(&furi_hal_i2c_handle_power))
|
||||
|
||||
@ -99,12 +99,16 @@ void furi_hal_power_reset();
|
||||
|
||||
/** OTG enable
|
||||
*/
|
||||
void furi_hal_power_enable_otg();
|
||||
bool furi_hal_power_enable_otg();
|
||||
|
||||
/** OTG disable
|
||||
*/
|
||||
void furi_hal_power_disable_otg();
|
||||
|
||||
/** Check OTG status fault
|
||||
*/
|
||||
bool furi_hal_power_check_otg_fault();
|
||||
|
||||
/** Check OTG status and disable it if falt happened
|
||||
*/
|
||||
void furi_hal_power_check_otg_status();
|
||||
|
||||
@ -61,7 +61,7 @@ void bq25896_init(FuriHalI2cBusHandle* handle) {
|
||||
|
||||
// OTG power configuration
|
||||
bq25896_regs.r0A.BOOSTV = 0x8; // BOOST Voltage: 5.062V
|
||||
bq25896_regs.r0A.BOOST_LIM = BOOST_LIM_1400; // BOOST Current limit: 1.4A
|
||||
bq25896_regs.r0A.BOOST_LIM = BoostLim_1400; // BOOST Current limit: 1.4A
|
||||
furi_hal_i2c_write_reg_8(
|
||||
handle, BQ25896_ADDRESS, 0x0A, *(uint8_t*)&bq25896_regs.r0A, BQ25896_I2C_TIMEOUT);
|
||||
|
||||
@ -74,6 +74,12 @@ void bq25896_init(FuriHalI2cBusHandle* handle) {
|
||||
BQ25896_I2C_TIMEOUT);
|
||||
}
|
||||
|
||||
void bq25896_set_boost_lim(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) {
|
||||
bq25896_regs.r09.BATFET_DIS = 1;
|
||||
furi_hal_i2c_write_reg_8(
|
||||
|
||||
@ -9,6 +9,9 @@
|
||||
/** Initialize Driver */
|
||||
void bq25896_init(FuriHalI2cBusHandle* handle);
|
||||
|
||||
/** Set boost lim*/
|
||||
void bq25896_set_boost_lim(FuriHalI2cBusHandle* handle, BoostLim boost_lim);
|
||||
|
||||
/** Send device into shipping mode */
|
||||
void bq25896_poweroff(FuriHalI2cBusHandle* handle);
|
||||
|
||||
|
||||
@ -159,14 +159,16 @@ typedef struct {
|
||||
#define BOOSTV_128 (1 << 1)
|
||||
#define BOOSTV_64 (1 << 0)
|
||||
|
||||
#define BOOST_LIM_500 (0b000)
|
||||
#define BOOST_LIM_750 (0b001)
|
||||
#define BOOST_LIM_1200 (0b010)
|
||||
#define BOOST_LIM_1400 (0b011)
|
||||
#define BOOST_LIM_1650 (0b100)
|
||||
#define BOOST_LIM_1875 (0b101)
|
||||
#define BOOST_LIM_2150 (0b110)
|
||||
#define BOOST_LIM_RSVD (0b111)
|
||||
typedef enum {
|
||||
BoostLim_500 = 0b000,
|
||||
BoostLim_750 = 0b001,
|
||||
BoostLim_1200 = 0b010,
|
||||
BoostLim_1400 = 0b011,
|
||||
BoostLim_1650 = 0b100,
|
||||
BoostLim_1875 = 0b101,
|
||||
BoostLim_2150 = 0b110,
|
||||
BoostLim_Rsvd = 0b111,
|
||||
} BoostLim;
|
||||
|
||||
typedef struct {
|
||||
uint8_t BOOST_LIM : 3; // Boost Mode Current Limit
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user