Skip to content

Commit

Permalink
Workaround for furi_hal_gpio_add_int_callback conflict with expansion
Browse files Browse the repository at this point in the history
Thanks @Willy-JL for all details about this issue
  • Loading branch information
xMasterX committed Feb 12, 2024
1 parent f43f8c3 commit 99f6bc2
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 1 deletion.
7 changes: 7 additions & 0 deletions apps_source_code/flipper_geiger/flipper_geiger.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <locale/locale.h>

#include <expansion/expansion.h>

#define SCREEN_SIZE_X 128
#define SCREEN_SIZE_Y 64

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 changes: 11 additions & 0 deletions base_pack/flipper_i2ctools/i2ctools.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "i2ctools_i.h"
#include <expansion/expansion.h>

void i2ctools_draw_callback(Canvas* canvas, void* ctx) {
furi_assert(ctx);
Expand Down Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 changes: 9 additions & 0 deletions non_catalog_apps/air_mouse_ofw/air_mouse_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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));
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 changes: 9 additions & 0 deletions non_catalog_apps/gb-pokemon-trading/pokemon_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
9 changes: 8 additions & 1 deletion non_catalog_apps/memsic_2125/memsic_2125_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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 changes: 7 additions & 0 deletions non_catalog_apps/step_counter/stepcounter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 changes: 8 additions & 0 deletions non_catalog_apps/wiegand/wiegand.c
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

0 comments on commit 99f6bc2

Please sign in to comment.