Просмотр исходного кода

do not reset 5v if it was enabled in gpio

esp flasher, wifi marauder, evil portal
MX 2 лет назад
Родитель
Сommit
05874086b6

+ 2 - 1
base_pack/wifi_marauder_companion/wifi_marauder_app.c

@@ -175,6 +175,7 @@ int32_t wifi_marauder_app(void* p) {
     UNUSED(p);
 
     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);
@@ -193,7 +194,7 @@ int32_t wifi_marauder_app(void* p) {
 
     wifi_marauder_app_free(wifi_marauder_app);
 
-    if(furi_hal_power_is_otg_enabled()) {
+    if(furi_hal_power_is_otg_enabled() && !otg_was_enabled) {
         furi_hal_power_disable_otg();
     }
 

+ 12 - 0
non_catalog_apps/flipper_evil_portal/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;
 }

+ 2 - 1
non_catalog_apps/flipperzero-esp-flasher/esp_flasher_app.c

@@ -116,6 +116,7 @@ int32_t esp_flasher_app(void* p) {
     UNUSED(p);
 
     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);
@@ -132,7 +133,7 @@ int32_t esp_flasher_app(void* p) {
 
     esp_flasher_app_free(esp_flasher_app);
 
-    if(furi_hal_power_is_otg_enabled()) {
+    if(furi_hal_power_is_otg_enabled() && !otg_was_enabled) {
         furi_hal_power_disable_otg();
     }