MX 2 лет назад
Родитель
Сommit
ccf5231b0d
1 измененных файлов с 10 добавлено и 3 удалено
  1. 10 3
      uhf_app.c

+ 10 - 3
uhf_app.c

@@ -197,15 +197,22 @@ int32_t uhf_app_main(void* ctx) {
     UHFApp* uhf_app = uhf_alloc();
     UHFApp* uhf_app = uhf_alloc();
 
 
     // enable 5v pin
     // enable 5v pin
-    furi_hal_power_enable_otg();
+     uint8_t attempts = 0;
+    bool otg_was_enabled = furi_hal_power_is_otg_enabled();
+    while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
+        furi_hal_power_enable_otg();
+        furi_delay_ms(10);
+    }
+    furi_delay_ms(200);
     // init pin a2
     // init pin a2
     // furi_hal_gpio_init_simple(&gpio_ext_pa7, GpioModeOutputPushPull);
     // furi_hal_gpio_init_simple(&gpio_ext_pa7, GpioModeOutputPushPull);
-    furi_hal_uart_set_br(FuriHalUartIdUSART1, DEFAULT_BAUDRATE);
     scene_manager_next_scene(uhf_app->scene_manager, UHFSceneModuleInfo);
     scene_manager_next_scene(uhf_app->scene_manager, UHFSceneModuleInfo);
     view_dispatcher_run(uhf_app->view_dispatcher);
     view_dispatcher_run(uhf_app->view_dispatcher);
 
 
     // disable 5v pin
     // disable 5v pin
-    furi_hal_power_disable_otg();
+     if(furi_hal_power_is_otg_enabled() && !otg_was_enabled) {
+        furi_hal_power_disable_otg();
+    }
     // furi_hal_gpio_disable_int_callback()
     // furi_hal_gpio_disable_int_callback()
     // exit app
     // exit app
     uhf_free(uhf_app);
     uhf_free(uhf_app);