diff --git a/applications/main/gpio/scenes/gpio_scene_start.c b/applications/main/gpio/scenes/gpio_scene_start.c index 4219364880..fdd48e5604 100644 --- a/applications/main/gpio/scenes/gpio_scene_start.c +++ b/applications/main/gpio/scenes/gpio_scene_start.c @@ -80,9 +80,9 @@ bool gpio_scene_start_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { if(event.event == GpioStartEventOtgOn) { - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } else if(event.event == GpioStartEventOtgOff) { - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } else if(event.event == GpioStartEventManualControl) { scene_manager_set_scene_state(app->scene_manager, GpioSceneStart, GpioItemTest); scene_manager_next_scene(app->scene_manager, GpioSceneTest); diff --git a/applications/main/infrared/infrared_app.c b/applications/main/infrared/infrared_app.c index dcd9f82d3a..3a31b6469f 100644 --- a/applications/main/infrared/infrared_app.c +++ b/applications/main/infrared/infrared_app.c @@ -460,9 +460,9 @@ void infrared_set_tx_pin(InfraredApp* infrared, FuriHalInfraredTxPin tx_pin) { void infrared_enable_otg(InfraredApp* infrared, bool enable) { if(enable) { - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } else { - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } infrared->app_state.is_otg_enabled = enable; } diff --git a/applications/main/onewire/onewire_cli.c b/applications/main/onewire/onewire_cli.c index 128b58743b..4ee81a462e 100644 --- a/applications/main/onewire/onewire_cli.c +++ b/applications/main/onewire/onewire_cli.c @@ -20,7 +20,7 @@ static void onewire_cli_search(Cli* cli) { printf("Search started\r\n"); onewire_host_start(onewire); - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); while(!done) { if(onewire_host_search(onewire, address, OneWireHostSearchModeNormal) != 1) { @@ -37,7 +37,7 @@ static void onewire_cli_search(Cli* cli) { furi_delay_ms(100); } - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); onewire_host_free(onewire); } diff --git a/applications/services/expansion/expansion_worker.c b/applications/services/expansion/expansion_worker.c index c05b9cc854..a000efd489 100644 --- a/applications/services/expansion/expansion_worker.c +++ b/applications/services/expansion/expansion_worker.c @@ -250,9 +250,9 @@ static bool expansion_worker_handle_state_connected( if(!expansion_worker_rpc_session_open(instance)) break; instance->state = ExpansionWorkerStateRpcActive; } else if(command == ExpansionFrameControlCommandEnableOtg) { - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } else if(command == ExpansionFrameControlCommandDisableOtg) { - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } else { break; } diff --git a/applications/services/rpc/rpc_gpio.c b/applications/services/rpc/rpc_gpio.c index 40fc898a09..9952bec38f 100644 --- a/applications/services/rpc/rpc_gpio.c +++ b/applications/services/rpc/rpc_gpio.c @@ -219,9 +219,9 @@ void rpc_system_gpio_set_otg_mode(const PB_Main* request, void* context) { const PB_Gpio_GpioOtgMode mode = request->content.gpio_set_otg_mode.mode; if(mode == PB_Gpio_GpioOtgMode_OFF) { - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } else { - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } rpc_send_and_release_empty(session, request->command_id, PB_CommandStatus_OK); diff --git a/lib/ibutton/ibutton_worker_modes.c b/lib/ibutton/ibutton_worker_modes.c index 5900b10a27..8efb78f039 100644 --- a/lib/ibutton/ibutton_worker_modes.c +++ b/lib/ibutton/ibutton_worker_modes.c @@ -75,7 +75,7 @@ void ibutton_worker_mode_idle_stop(iButtonWorker* worker) { void ibutton_worker_mode_read_start(iButtonWorker* worker) { UNUSED(worker); - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } void ibutton_worker_mode_read_tick(iButtonWorker* worker) { @@ -90,7 +90,7 @@ void ibutton_worker_mode_read_tick(iButtonWorker* worker) { void ibutton_worker_mode_read_stop(iButtonWorker* worker) { UNUSED(worker); - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } /*********************** EMULATE ***********************/ @@ -120,7 +120,7 @@ void ibutton_worker_mode_emulate_stop(iButtonWorker* worker) { void ibutton_worker_mode_write_common_start(iButtonWorker* worker) { //-V524 UNUSED(worker); - furi_hal_power_enable_otg(); + if(!furi_hal_power_is_otg_enabled()) furi_hal_power_enable_otg(); } void ibutton_worker_mode_write_id_tick(iButtonWorker* worker) { @@ -149,5 +149,5 @@ void ibutton_worker_mode_write_copy_tick(iButtonWorker* worker) { void ibutton_worker_mode_write_common_stop(iButtonWorker* worker) { //-V524 UNUSED(worker); - furi_hal_power_disable_otg(); + if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); }