frux-c пре 1 година
родитељ
комит
2b48fc740e
2 измењених фајлова са 10 додато и 6 уклоњено
  1. 10 4
      uhf_app.c
  2. 0 2
      uhf_uart.c

+ 10 - 4
uhf_app.c

@@ -195,14 +195,20 @@ void uhf_show_loading_popup(void* ctx, bool show) {
 
 int32_t uhf_app_main(void* ctx) {
     UNUSED(ctx);
+    bool is_5v_enabled_by_app = false;
+    // enable 5v pin if not enabled
+    if(!furi_hal_power_is_otg_enabled()) {
+        furi_hal_power_enable_otg();
+        is_5v_enabled_by_app = true;
+    }
     UHFApp* uhf_app = uhf_alloc();
-    // enable 5v pin
-    furi_hal_power_enable_otg();
     // enter app
     scene_manager_next_scene(uhf_app->scene_manager, UHFSceneModuleInfo);
     view_dispatcher_run(uhf_app->view_dispatcher);
-    // disable 5v pin
-    furi_hal_power_disable_otg();
+    // disable 5v pin if enabled by app
+    if(is_5v_enabled_by_app) {
+        furi_hal_power_disable_otg();
+    }
     // exit app
     uhf_free(uhf_app);
     return 0;

+ 0 - 2
uhf_uart.c

@@ -70,8 +70,6 @@ UHFUart* uhf_uart_alloc(){
         FURI_LOG_E("UHF_UART", "UHF UART INIT BY HAL");
     }
     uart->buffer = uhf_buffer_alloc(UHF_UART_RX_BUFFER_SIZE);
-    // uart->thread = furi_thread_alloc_ex("UHFUartWorker", UHF_UART_WORKER_STACK_SIZE, uhf_uart_worker_callback, uart);
-    // furi_thread_start(uart->thread);
     furi_hal_serial_async_rx_start(uart->handle, uhf_uart_default_rx_callback, uart, false);
     return uart;
 }