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

fix uart related plugins to disable expansion protocol

MX 1 год назад
Родитель
Сommit
2a405c0b28
1 измененных файлов с 12 добавлено и 0 удалено
  1. 12 0
      gps.c

+ 12 - 0
gps.c

@@ -4,6 +4,7 @@
 #include <furi.h>
 #include <gui/gui.h>
 #include <string.h>
+#include <expansion/expansion.h>
 
 typedef enum {
     EventTypeTick,
@@ -131,6 +132,10 @@ static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queu
 int32_t gps_app(void* p) {
     UNUSED(p);
 
+    // Disable expansion protocol to avoid interference with UART Handle
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
 
     GpsUart* gps_uart = gps_uart_enable();
@@ -139,6 +144,9 @@ int32_t gps_app(void* p) {
     if(!gps_uart->mutex) {
         FURI_LOG_E("GPS", "cannot create mutex\r\n");
         free(gps_uart);
+        // Return previous state of expansion
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return 255;
     }
 
@@ -271,5 +279,9 @@ int32_t gps_app(void* p) {
         furi_hal_power_disable_otg();
     }
 
+    // Return previous state of expansion
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }