Переглянути джерело

Fix remaining UART apps for expansion changes

Willy-JL 1 рік тому
батько
коміт
387778c312

+ 9 - 0
esp_flasher/esp_flasher_app.c

@@ -2,6 +2,7 @@
 
 #include <furi.h>
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 static bool esp_flasher_app_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -118,6 +119,10 @@ void esp_flasher_app_free(EspFlasherApp* app) {
 int32_t esp_flasher_app(void* p) {
     UNUSED(p);
 
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     uint8_t attempts = 0;
     bool otg_was_enabled = furi_hal_power_is_otg_enabled();
     while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
@@ -140,5 +145,9 @@ int32_t esp_flasher_app(void* p) {
         furi_hal_power_disable_otg();
     }
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 10 - 0
mayhem_camera/camera.c

@@ -1,5 +1,7 @@
 #include "camera.h"
 
+#include <expansion/expansion.h>
+
 static void camera_view_draw_callback(Canvas* canvas, void* _model) {
     UartDumpModel* model = _model;
 
@@ -305,11 +307,19 @@ static void camera_app_free(UartEchoApp* app) {
 int32_t camera_app(void* p) {
     UNUSED(p);
 
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     UartEchoApp* app = camera_app_alloc();
     view_dispatcher_run(app->view_dispatcher);
     camera_app_free(app);
 
     furi_hal_power_disable_otg();
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 10 - 0
mayhem_marauder/wifi_marauder_app.c

@@ -2,6 +2,7 @@
 
 #include <furi.h>
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 static bool wifi_marauder_app_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -171,6 +172,11 @@ void wifi_marauder_app_free(WifiMarauderApp* app) {
 
 int32_t wifi_marauder_app(void* p) {
     UNUSED(p);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     uint8_t attempts = 0;
     while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
         furi_hal_power_enable_otg();
@@ -199,5 +205,9 @@ int32_t wifi_marauder_app(void* p) {
         furi_hal_power_disable_otg();
     }
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 9 - 0
mayhem_morseflash/uart_terminal_app.c

@@ -2,6 +2,7 @@
 
 #include <furi.h>
 #include <furi_hal.h>
+#include <expansion/expansion.h>
 
 static bool uart_terminal_app_custom_event_callback(void* context, uint32_t event) {
     furi_assert(context);
@@ -91,6 +92,10 @@ void uart_terminal_app_free(UART_TerminalApp* app) {
 int32_t uart_terminal_app(void* p) {
     UNUSED(p);
 
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     furi_hal_power_disable_external_3_3v();
     furi_hal_power_disable_otg();
     furi_delay_ms(200);
@@ -112,5 +117,9 @@ int32_t uart_terminal_app(void* p) {
 
     furi_hal_power_disable_otg();
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 12 - 0
mayhem_motion/uart_echo.c

@@ -1,5 +1,7 @@
 #include "uart_echo.h"
 
+#include <expansion/expansion.h>
+
 static void uart_echo_view_draw_callback(Canvas* canvas, void* _model) {
     UartDumpModel* model = _model;
 
@@ -236,9 +238,19 @@ static void uart_echo_app_free(UartEchoApp* app) {
 
 int32_t uart_echo_app(void* p) {
     UNUSED(p);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     UartEchoApp* app = uart_echo_app_alloc();
     view_dispatcher_run(app->view_dispatcher);
     uart_echo_app_free(app);
     furi_hal_power_disable_otg();
+
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 12 - 0
mayhem_nannycam/uart_echo.c

@@ -1,5 +1,7 @@
 #include "uart_echo.h"
 
+#include <expansion/expansion.h>
+
 static void uart_echo_view_draw_callback(Canvas* canvas, void* _model) {
     UartDumpModel* model = _model;
 
@@ -230,9 +232,19 @@ static void uart_echo_app_free(UartEchoApp* app) {
 
 int32_t uart_echo_app(void* p) {
     UNUSED(p);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     UartEchoApp* app = uart_echo_app_alloc();
     view_dispatcher_run(app->view_dispatcher);
     uart_echo_app_free(app);
     furi_hal_power_disable_otg();
+
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 12 - 0
mayhem_qrcode/uart_echo.c

@@ -1,5 +1,7 @@
 #include "uart_echo.h"
 
+#include <expansion/expansion.h>
+
 static void uart_echo_view_draw_callback(Canvas* canvas, void* _model) {
     UartDumpModel* model = _model;
 
@@ -230,9 +232,19 @@ static void uart_echo_app_free(UartEchoApp* app) {
 
 int32_t uart_echo_app(void* p) {
     UNUSED(p);
+
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     UartEchoApp* app = uart_echo_app_alloc();
     view_dispatcher_run(app->view_dispatcher);
     uart_echo_app_free(app);
     furi_hal_power_disable_otg();
+
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 10 - 0
wardriver/wardriver.c

@@ -1,6 +1,8 @@
 #include "wardriver.h"
 #include "wardriver_uart.h"
 
+#include <expansion/expansion.h>
+
 void save_file(Context* ctx) {
     Storage* storage = furi_record_open(RECORD_STORAGE);
     FuriHalRtcDateTime datetime;
@@ -226,6 +228,10 @@ static void render_callback(Canvas* canvas, void* context) {
 }
 
 int32_t wardriver_app() {
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     // turn off 5v, so it gets reset on startup
     if(furi_hal_power_is_otg_enabled()) {
         furi_hal_power_disable_otg();
@@ -346,5 +352,9 @@ int32_t wardriver_app() {
         furi_hal_power_disable_otg();
     }
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }