AVR ISP enable 5v power on start

This commit is contained in:
MX 2023-04-02 01:11:23 +03:00
parent dce5bfd723
commit 3d5701614f
No known key found for this signature in database
GPG Key ID: 7CCC66B7DBDD1C83

View File

@ -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);
}