Jelajahi Sumber

do not reset 5v if it was enabled in gpio

esp flasher, wifi marauder, evil portal
MX 2 tahun lalu
induk
melakukan
1edaa675b1
1 mengubah file dengan 12 tambahan dan 0 penghapusan
  1. 12 0
      evil_portal_app.c

+ 12 - 0
evil_portal_app.c

@@ -124,11 +124,23 @@ int32_t evil_portal_app(void* p) {
     UNUSED(p);
     Evil_PortalApp* evil_portal_app = evil_portal_app_alloc();
 
+    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);
+
     evil_portal_app->uart = evil_portal_uart_init(evil_portal_app);
 
     view_dispatcher_run(evil_portal_app->view_dispatcher);
 
     evil_portal_app_free(evil_portal_app);
 
+    if(furi_hal_power_is_otg_enabled() && !otg_was_enabled) {
+        furi_hal_power_disable_otg();
+    }
+
     return 0;
 }