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

Workaround for furi_hal_gpio_add_int_callback conflict with expansion

Thanks @Willy-JL for all details about this issue
MX 1 год назад
Родитель
Сommit
99f6bc25be

+ 7 - 0
apps_source_code/flipper_geiger/flipper_geiger.c

@@ -16,6 +16,8 @@
 
 #include <locale/locale.h>
 
+#include <expansion/expansion.h>
+
 #define SCREEN_SIZE_X 128
 #define SCREEN_SIZE_Y 64
 
@@ -175,6 +177,8 @@ int32_t flipper_geiger_app()
     mutexVal.mutex= furi_mutex_alloc(FuriMutexTypeNormal);
     if(!mutexVal.mutex) {
         furi_message_queue_free(event_queue);
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return 255;
     }
 
@@ -379,5 +383,8 @@ int32_t flipper_geiger_app()
     furi_timer_free(timer);
     furi_record_close(RECORD_GUI);
 
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 11 - 0
base_pack/flipper_i2ctools/i2ctools.c

@@ -1,4 +1,5 @@
 #include "i2ctools_i.h"
+#include <expansion/expansion.h>
 
 void i2ctools_draw_callback(Canvas* canvas, void* ctx) {
     furi_assert(ctx);
@@ -40,6 +41,10 @@ void i2ctools_input_callback(InputEvent* input_event, void* ctx) {
 
 int32_t i2ctools_app(void* p) {
     UNUSED(p);
+
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
 
     // Alloc i2ctools
@@ -48,6 +53,8 @@ int32_t i2ctools_app(void* p) {
     if(!i2ctools->mutex) {
         FURI_LOG_E(APP_NAME, "cannot create mutex\r\n");
         free(i2ctools);
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return -1;
     }
 
@@ -227,5 +234,9 @@ int32_t i2ctools_app(void* p) {
     furi_mutex_free(i2ctools->mutex);
     free(i2ctools);
     furi_record_close(RECORD_GUI);
+
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 9 - 0
non_catalog_apps/air_mouse_ofw/air_mouse_app.c

@@ -10,6 +10,7 @@
 #include "views/air_mouse_view.h"
 #include <furi_hal_usb_hid.h>
 #include <storage/storage.h>
+#include <expansion/expansion.h>
 
 #define TAG "SensorModule"
 
@@ -211,6 +212,10 @@ static void air_mouse_free(AirMouseApp* app) {
 
 int32_t air_mouse_app(void* arg) {
     UNUSED(arg);
+
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     AirMouseApp* app = air_mouse_alloc();
 
     app->icm42688p_device = malloc(sizeof(FuriHalSpiBusHandle));
@@ -236,5 +241,9 @@ int32_t air_mouse_app(void* arg) {
     free(app->icm42688p_device);
 
     air_mouse_free(app);
+
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 9 - 0
non_catalog_apps/flipper_atomicdiceroller/flipper_atomicdiceroller.c

@@ -11,6 +11,7 @@
 #include <locale/locale.h>
 #include <toolbox/crc32_calc.h>
 #include <mbedtls/md5.h>
+#include <expansion/expansion.h>
 
 #define SCREEN_SIZE_X 128
 #define SCREEN_SIZE_Y 64
@@ -96,6 +97,9 @@ static void gpiocallback(void* ctx) {
 }
 
 int32_t flipper_atomicdiceroller_app() {
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+    
     furi_hal_bus_enable(FuriHalBusTIM2);
     LL_TIM_SetCounterMode(TIM2, LL_TIM_COUNTERMODE_UP);
     LL_TIM_SetClockDivision(TIM2, LL_TIM_CLOCKDIVISION_DIV1);
@@ -119,6 +123,8 @@ int32_t flipper_atomicdiceroller_app() {
     mutexVal.mutex = furi_mutex_alloc(FuriMutexTypeNormal);
     if(!mutexVal.mutex) {
         furi_message_queue_free(event_queue);
+        expansion_enable(expansion);
+        furi_record_close(RECORD_EXPANSION);
         return 255;
     }
 
@@ -350,5 +356,8 @@ int32_t flipper_atomicdiceroller_app() {
     furi_timer_free(timerPause);
     furi_record_close(RECORD_GUI);
 
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 9 - 0
non_catalog_apps/gb-pokemon-trading/pokemon_app.c

@@ -8,6 +8,8 @@
 #include "pokemon_app.h"
 #include "pokemon_char_encode.h"
 
+#include <expansion/expansion.h>
+
 const PokemonTable pokemon_table[] = {
     /* Values for base_*, moves, etc., pulled directly from a copy of Pokemon Blue */
     {"Bulbasaur",
@@ -2250,6 +2252,10 @@ void free_app(PokemonFap* pokemon_fap) {
 
 int32_t pokemon_app(void* p) {
     UNUSED(p);
+
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     PokemonFap* pokemon_fap = pokemon_alloc();
 
     furi_hal_light_set(LightRed, 0x00);
@@ -2262,5 +2268,8 @@ int32_t pokemon_app(void* p) {
     // Free resources
     free_app(pokemon_fap);
 
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 8 - 1
non_catalog_apps/memsic_2125/memsic_2125_app.c

@@ -28,6 +28,8 @@ Pin 6  - Vdd  - Drain voltage (3.3V to 5V DC)              - 3v3
 #include <notification/notification.h>
 #include <notification/notification_messages.h>
 
+#include <expansion/expansion.h>
+
 #define TAG "memsic_2125_app"
 
 typedef enum {
@@ -138,7 +140,9 @@ static void render_callback(Canvas* canvas, void* ctx) {
 // Program entry point
 int32_t memsic_2125_app(void* p) {
     UNUSED(p);
-
+    
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
     // Configure our initial data.
     DemoContext* demo_context = malloc(sizeof(DemoContext));
     demo_context->data = malloc(sizeof(DemoData));
@@ -223,5 +227,8 @@ int32_t memsic_2125_app(void* p) {
     free(demo_context->data);
     free(demo_context);
 
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+
     return 0;
 }

+ 7 - 0
non_catalog_apps/step_counter/stepcounter.c

@@ -7,6 +7,7 @@
 #include <locale/locale.h>
 #include <notification/notification.h>
 #include <notification/notification_messages.h>
+#include <expansion/expansion.h>
 
 #define TAG_MEMSIC "memsic_2125_app"
 #define TAG_COUNTER "step_counter_app"
@@ -95,6 +96,9 @@ static void render_callback(Canvas* canvas, void* ctx) {
 int32_t step_counter_app(void* p) {
     UNUSED(p);
 
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     StepCounterContext* stepContext = malloc(sizeof(StepCounterContext));
     stepContext->data = malloc(sizeof(StepCounterData));
     stepContext->data->pin = gpio_accelerometer;
@@ -152,5 +156,8 @@ int32_t step_counter_app(void* p) {
     free(stepContext->data);
     free(stepContext);
 
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
+    
     return 0;
 }

+ 8 - 0
non_catalog_apps/wiegand/wiegand.c

@@ -1,4 +1,5 @@
 #include "wiegand.h"
+#include <expansion/expansion.h>
 
 const GpioPin* const pinD0 = &gpio_ext_pa4;
 const GpioPin* const pinD0mosfet = &gpio_ext_pb3;
@@ -112,6 +113,10 @@ void app_free(void* context) {
 
 int wiegand_app(void* p) {
     UNUSED(p);
+
+    Expansion* expansion = furi_record_open(RECORD_EXPANSION);
+    expansion_disable(expansion);
+
     App* app = app_alloc();
 
     Gui* gui = furi_record_open(RECORD_GUI);
@@ -120,5 +125,8 @@ int wiegand_app(void* p) {
     view_dispatcher_run(app->view_dispatcher);
 
     app_free(app);
+
+    expansion_enable(expansion);
+    furi_record_close(RECORD_EXPANSION);
     return 0;
 }