From 3d5701614f5f9de820b37bb6812ff5f359bac8be Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 2 Apr 2023 01:11:23 +0300 Subject: [PATCH] AVR ISP enable 5v power on start --- .../external/avr_isp_programmer/avr_isp_app.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/applications/external/avr_isp_programmer/avr_isp_app.c b/applications/external/avr_isp_programmer/avr_isp_app.c index e582834c6..e199f0c12 100644 --- a/applications/external/avr_isp_programmer/avr_isp_app.c +++ b/applications/external/avr_isp_programmer/avr_isp_app.c @@ -21,6 +21,13 @@ static void avr_isp_app_tick_event_callback(void* context) { AvrIspApp* avr_isp_app_alloc() { AvrIspApp* app = malloc(sizeof(AvrIspApp)); + // Enable 5v power, multiple attempts to avoid issues with power chip protection false triggering + uint8_t attempts = 0; + while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) { + furi_hal_power_enable_otg(); + furi_delay_ms(10); + } + app->file_path = furi_string_alloc(); furi_string_set(app->file_path, STORAGE_APP_DATA_PATH_PREFIX); app->error = AvrIspErrorNoError; @@ -152,6 +159,11 @@ void avr_isp_app_free(AvrIspApp* app) { // Path strings furi_string_free(app->file_path); + // Disable 5v power + if(furi_hal_power_is_otg_enabled()) { + furi_hal_power_disable_otg(); + } + free(app); }