mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-09 05:49:09 -07:00
Merge remote-tracking branch 'ofw/dev' into mntm-dev
This commit is contained in:
@@ -842,7 +842,7 @@ Function,+,canvas_draw_str,void,"Canvas*, int32_t, int32_t, const char*"
|
||||
Function,+,canvas_draw_str_aligned,void,"Canvas*, int32_t, int32_t, Align, Align, const char*"
|
||||
Function,+,canvas_draw_triangle,void,"Canvas*, int32_t, int32_t, size_t, size_t, CanvasDirection"
|
||||
Function,+,canvas_draw_xbm,void,"Canvas*, int32_t, int32_t, size_t, size_t, const uint8_t*"
|
||||
Function,+,canvas_draw_xbm_custom,void,"Canvas*, int32_t, int32_t, size_t, size_t, IconRotation, const uint8_t*"
|
||||
Function,+,canvas_draw_xbm_ex,void,"Canvas*, int32_t, int32_t, size_t, size_t, IconRotation, const uint8_t*"
|
||||
Function,+,canvas_get_font_params,const CanvasFontParameters*,"const Canvas*, Font"
|
||||
Function,+,canvas_glyph_width,size_t,"Canvas*, uint16_t"
|
||||
Function,+,canvas_height,size_t,const Canvas*
|
||||
@@ -1263,6 +1263,7 @@ Function,-,ftello,off_t,FILE*
|
||||
Function,-,ftrylockfile,int,FILE*
|
||||
Function,-,funlockfile,void,FILE*
|
||||
Function,-,funopen,FILE*,"const void*, int (*)(void*, char*, int), int (*)(void*, const char*, int), fpos_t (*)(void*, fpos_t, int), int (*)(void*)"
|
||||
Function,-,furi_background,void,
|
||||
Function,+,furi_delay_ms,void,uint32_t
|
||||
Function,+,furi_delay_tick,void,uint32_t
|
||||
Function,+,furi_delay_until_tick,FuriStatus,uint32_t
|
||||
@@ -1275,6 +1276,7 @@ Function,+,furi_event_flag_set,uint32_t,"FuriEventFlag*, uint32_t"
|
||||
Function,+,furi_event_flag_wait,uint32_t,"FuriEventFlag*, uint32_t, uint32_t, uint32_t"
|
||||
Function,+,furi_event_loop_alloc,FuriEventLoop*,
|
||||
Function,+,furi_event_loop_free,void,FuriEventLoop*
|
||||
Function,+,furi_event_loop_is_subscribed,_Bool,"FuriEventLoop*, FuriEventLoopObject*"
|
||||
Function,+,furi_event_loop_pend_callback,void,"FuriEventLoop*, FuriEventLoopPendingCallback, void*"
|
||||
Function,+,furi_event_loop_run,void,FuriEventLoop*
|
||||
Function,+,furi_event_loop_stop,void,FuriEventLoop*
|
||||
@@ -1597,6 +1599,8 @@ Function,-,furi_hal_resources_deinit_early,void,
|
||||
Function,+,furi_hal_resources_get_ext_pin_number,int32_t,const GpioPin*
|
||||
Function,-,furi_hal_resources_init,void,
|
||||
Function,-,furi_hal_resources_init_early,void,
|
||||
Function,+,furi_hal_resources_pin_by_name,const GpioPinRecord*,const char*
|
||||
Function,+,furi_hal_resources_pin_by_number,const GpioPinRecord*,uint8_t
|
||||
Function,+,furi_hal_rfid_comp_set_callback,void,"FuriHalRfidCompCallback, void*"
|
||||
Function,+,furi_hal_rfid_comp_start,void,
|
||||
Function,+,furi_hal_rfid_comp_stop,void,
|
||||
@@ -1958,6 +1962,7 @@ Function,+,furi_thread_stdout_write,size_t,"const char*, size_t"
|
||||
Function,+,furi_thread_suspend,void,FuriThreadId
|
||||
Function,+,furi_thread_yield,void,
|
||||
Function,+,furi_timer_alloc,FuriTimer*,"FuriTimerCallback, FuriTimerType, void*"
|
||||
Function,+,furi_timer_flush,void,
|
||||
Function,+,furi_timer_free,void,FuriTimer*
|
||||
Function,-,furi_timer_get_current_name,const char*,
|
||||
Function,+,furi_timer_get_expire_time,uint32_t,FuriTimer*
|
||||
@@ -3753,6 +3758,7 @@ Function,+,view_allocate_model,void,"View*, ViewModelType, size_t"
|
||||
Function,+,view_commit_model,void,"View*, _Bool"
|
||||
Function,+,view_dispatcher_add_view,void,"ViewDispatcher*, uint32_t, View*"
|
||||
Function,+,view_dispatcher_alloc,ViewDispatcher*,
|
||||
Function,+,view_dispatcher_alloc_ex,ViewDispatcher*,FuriEventLoop*
|
||||
Function,+,view_dispatcher_attach_to_gui,void,"ViewDispatcher*, Gui*, ViewDispatcherType"
|
||||
Function,+,view_dispatcher_enable_queue,void,ViewDispatcher*
|
||||
Function,+,view_dispatcher_free,void,ViewDispatcher*
|
||||
|
||||
|
@@ -87,6 +87,8 @@ void ble_glue_init(void) {
|
||||
TL_Init();
|
||||
|
||||
ble_glue->shci_mtx = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
// Take mutex, SHCI will release it in most unusual way later
|
||||
furi_check(furi_mutex_acquire(ble_glue->shci_mtx, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
// FreeRTOS system task creation
|
||||
ble_event_thread_start();
|
||||
@@ -248,7 +250,9 @@ void ble_glue_stop(void) {
|
||||
ble_event_thread_stop();
|
||||
// Free resources
|
||||
furi_mutex_free(ble_glue->shci_mtx);
|
||||
ble_glue->shci_mtx = NULL;
|
||||
furi_timer_free(ble_glue->hardfault_check_timer);
|
||||
ble_glue->hardfault_check_timer = NULL;
|
||||
|
||||
ble_glue_clear_shared_memory();
|
||||
free(ble_glue);
|
||||
@@ -309,10 +313,13 @@ BleGlueCommandResult ble_glue_force_c2_mode(BleGlueC2Mode desired_mode) {
|
||||
static void ble_sys_status_not_callback(SHCI_TL_CmdStatus_t status) {
|
||||
switch(status) {
|
||||
case SHCI_TL_CmdBusy:
|
||||
furi_mutex_acquire(ble_glue->shci_mtx, FuriWaitForever);
|
||||
furi_check(
|
||||
furi_mutex_acquire(
|
||||
ble_glue->shci_mtx, furi_kernel_is_running() ? FuriWaitForever : 0) ==
|
||||
FuriStatusOk);
|
||||
break;
|
||||
case SHCI_TL_CmdAvailable:
|
||||
furi_mutex_release(ble_glue->shci_mtx);
|
||||
furi_check(furi_mutex_release(ble_glue->shci_mtx) == FuriStatusOk);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -144,7 +144,7 @@ BleEventFlowStatus ble_event_app_notification(void* pckt) {
|
||||
event_pckt = (hci_event_pckt*)((hci_uart_pckt*)pckt)->data;
|
||||
|
||||
furi_check(gap);
|
||||
furi_mutex_acquire(gap->state_mutex, FuriWaitForever);
|
||||
furi_check(furi_mutex_acquire(gap->state_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
||||
switch(event_pckt->evt) {
|
||||
case HCI_DISCONNECTION_COMPLETE_EVT_CODE: {
|
||||
@@ -328,7 +328,7 @@ BleEventFlowStatus ble_event_app_notification(void* pckt) {
|
||||
break;
|
||||
}
|
||||
|
||||
furi_mutex_release(gap->state_mutex);
|
||||
furi_check(furi_mutex_release(gap->state_mutex) == FuriStatusOk);
|
||||
|
||||
return BleEventFlowEnable;
|
||||
}
|
||||
@@ -514,7 +514,7 @@ static void gap_advertise_stop(void) {
|
||||
}
|
||||
|
||||
void gap_start_advertising(void) {
|
||||
furi_mutex_acquire(gap->state_mutex, FuriWaitForever);
|
||||
furi_check(furi_mutex_acquire(gap->state_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
if(gap->state == GapStateIdle) {
|
||||
gap->state = GapStateStartingAdv;
|
||||
FURI_LOG_I(TAG, "Start advertising");
|
||||
@@ -522,18 +522,18 @@ void gap_start_advertising(void) {
|
||||
GapCommand command = GapCommandAdvFast;
|
||||
furi_check(furi_message_queue_put(gap->command_queue, &command, 0) == FuriStatusOk);
|
||||
}
|
||||
furi_mutex_release(gap->state_mutex);
|
||||
furi_check(furi_mutex_release(gap->state_mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void gap_stop_advertising(void) {
|
||||
furi_mutex_acquire(gap->state_mutex, FuriWaitForever);
|
||||
furi_check(furi_mutex_acquire(gap->state_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
if(gap->state > GapStateIdle) {
|
||||
FURI_LOG_I(TAG, "Stop advertising");
|
||||
gap->enable_adv = false;
|
||||
GapCommand command = GapCommandAdvStop;
|
||||
furi_check(furi_message_queue_put(gap->command_queue, &command, 0) == FuriStatusOk);
|
||||
}
|
||||
furi_mutex_release(gap->state_mutex);
|
||||
furi_check(furi_mutex_release(gap->state_mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
static void gap_advertise_timer_callback(void* context) {
|
||||
@@ -604,9 +604,9 @@ uint32_t gap_get_remote_conn_rssi(int8_t* rssi) {
|
||||
GapState gap_get_state(void) {
|
||||
GapState state;
|
||||
if(gap) {
|
||||
furi_mutex_acquire(gap->state_mutex, FuriWaitForever);
|
||||
furi_check(furi_mutex_acquire(gap->state_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
state = gap->state;
|
||||
furi_mutex_release(gap->state_mutex);
|
||||
furi_check(furi_mutex_release(gap->state_mutex) == FuriStatusOk);
|
||||
} else {
|
||||
state = GapStateUninitialized;
|
||||
}
|
||||
@@ -615,17 +615,21 @@ GapState gap_get_state(void) {
|
||||
|
||||
void gap_thread_stop(void) {
|
||||
if(gap) {
|
||||
furi_mutex_acquire(gap->state_mutex, FuriWaitForever);
|
||||
furi_check(furi_mutex_acquire(gap->state_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
gap->enable_adv = false;
|
||||
GapCommand command = GapCommandKillThread;
|
||||
furi_message_queue_put(gap->command_queue, &command, FuriWaitForever);
|
||||
furi_mutex_release(gap->state_mutex);
|
||||
furi_check(furi_mutex_release(gap->state_mutex) == FuriStatusOk);
|
||||
furi_thread_join(gap->thread);
|
||||
furi_thread_free(gap->thread);
|
||||
gap->thread = NULL;
|
||||
// Free resources
|
||||
furi_mutex_free(gap->state_mutex);
|
||||
gap->state_mutex = NULL;
|
||||
furi_message_queue_free(gap->command_queue);
|
||||
gap->command_queue = NULL;
|
||||
furi_timer_free(gap->advertise_timer);
|
||||
gap->advertise_timer = NULL;
|
||||
|
||||
ble_event_dispatcher_reset();
|
||||
free(gap);
|
||||
@@ -642,7 +646,7 @@ static int32_t gap_app(void* context) {
|
||||
FURI_LOG_E(TAG, "Message queue get error: %d", status);
|
||||
continue;
|
||||
}
|
||||
furi_mutex_acquire(gap->state_mutex, FuriWaitForever);
|
||||
furi_check(furi_mutex_acquire(gap->state_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
if(command == GapCommandKillThread) {
|
||||
break;
|
||||
}
|
||||
@@ -653,7 +657,7 @@ static int32_t gap_app(void* context) {
|
||||
} else if(command == GapCommandAdvStop) {
|
||||
gap_advertise_stop();
|
||||
}
|
||||
furi_mutex_release(gap->state_mutex);
|
||||
furi_check(furi_mutex_release(gap->state_mutex) == FuriStatusOk);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -288,3 +288,19 @@ int32_t furi_hal_resources_get_ext_pin_number(const GpioPin* gpio) {
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
const GpioPinRecord* furi_hal_resources_pin_by_name(const char* name) {
|
||||
for(size_t i = 0; i < gpio_pins_count; i++) {
|
||||
const GpioPinRecord* record = &gpio_pins[i];
|
||||
if(strcasecmp(name, record->name) == 0) return record;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const GpioPinRecord* furi_hal_resources_pin_by_number(uint8_t number) {
|
||||
for(size_t i = 0; i < gpio_pins_count; i++) {
|
||||
const GpioPinRecord* record = &gpio_pins[i];
|
||||
if(record->number == number) return record;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -227,6 +227,26 @@ void furi_hal_resources_init(void);
|
||||
*/
|
||||
int32_t furi_hal_resources_get_ext_pin_number(const GpioPin* gpio);
|
||||
|
||||
/**
|
||||
* @brief Finds a pin by its name
|
||||
*
|
||||
* @param name case-insensitive pin name to look for (e.g. `"Pc3"`, `"pA4"`)
|
||||
*
|
||||
* @return a pointer to the corresponding `GpioPinRecord` if such a pin exists,
|
||||
* `NULL` otherwise.
|
||||
*/
|
||||
const GpioPinRecord* furi_hal_resources_pin_by_name(const char* name);
|
||||
|
||||
/**
|
||||
* @brief Finds a pin by its number
|
||||
*
|
||||
* @param name pin number to look for (e.g. `7`, `4`)
|
||||
*
|
||||
* @return a pointer to the corresponding `GpioPinRecord` if such a pin exists,
|
||||
* `NULL` otherwise.
|
||||
*/
|
||||
const GpioPinRecord* furi_hal_resources_pin_by_number(uint8_t number);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -202,7 +202,7 @@ bool furi_hal_spi_bus_trx_dma(
|
||||
furi_check(size > 0);
|
||||
|
||||
// If scheduler is not running, use blocking mode
|
||||
if(furi_kernel_is_running()) {
|
||||
if(!furi_kernel_is_running()) {
|
||||
return furi_hal_spi_bus_trx(handle, tx_buffer, rx_buffer, size, timeout_ms);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,7 @@ to exclude the API function. */
|
||||
#define INCLUDE_xTaskGetCurrentTaskHandle 1
|
||||
#define INCLUDE_xTaskGetSchedulerState 1
|
||||
#define INCLUDE_xTimerPendFunctionCall 1
|
||||
#define INCLUDE_xTaskGetIdleTaskHandle 1
|
||||
|
||||
/* Workaround for various notification issues:
|
||||
* - First one used by system primitives
|
||||
@@ -129,25 +130,11 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
|
||||
#define configMAX_SYSCALL_INTERRUPT_PRIORITY \
|
||||
(configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS))
|
||||
|
||||
/* Normal assert() semantics without relying on the provision of an assert.h
|
||||
header file. */
|
||||
#ifdef DEBUG
|
||||
#include <core/check.h>
|
||||
#define configASSERT(x) \
|
||||
if((x) == 0) { \
|
||||
furi_crash("FreeRTOS Assert"); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
|
||||
standard names. */
|
||||
#define vPortSVCHandler SVC_Handler
|
||||
#define xPortPendSVHandler PendSV_Handler
|
||||
|
||||
#define USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION 1
|
||||
#define configOVERRIDE_DEFAULT_TICK_CONFIGURATION \
|
||||
1 /* required only for Keil but does not hurt otherwise */
|
||||
|
||||
#define traceTASK_SWITCHED_IN() \
|
||||
extern void furi_hal_mpu_set_stack_protection(uint32_t* stack); \
|
||||
furi_hal_mpu_set_stack_protection((uint32_t*)pxCurrentTCB->pxStack); \
|
||||
@@ -157,6 +144,14 @@ standard names. */
|
||||
// referencing `FreeRTOS_errno' here vvvvv because FreeRTOS calls our hook _before_ copying the value into the TCB, hence a manual write to the TCB would get overwritten
|
||||
#define traceTASK_SWITCHED_OUT() FreeRTOS_errno = errno
|
||||
|
||||
#define portCLEAN_UP_TCB(pxTCB) \
|
||||
extern void furi_thread_cleanup_tcb_event(TaskHandle_t task); \
|
||||
furi_thread_cleanup_tcb_event(pxTCB)
|
||||
/* Normal assert() semantics without relying on the provision of an assert.h
|
||||
header file. */
|
||||
#ifdef DEBUG
|
||||
#define configASSERT(x) \
|
||||
if((x) == 0) { \
|
||||
furi_crash("FreeRTOS Assert"); \
|
||||
}
|
||||
#endif
|
||||
|
||||
// Must be last line of config because of recursion
|
||||
#include <core/check.h>
|
||||
|
||||
@@ -15,6 +15,8 @@ int32_t init_task(void* context) {
|
||||
// Init flipper
|
||||
flipper_init();
|
||||
|
||||
furi_background();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -26,7 +28,8 @@ int main(void) {
|
||||
furi_hal_init_early();
|
||||
|
||||
furi_hal_set_is_normal_boot(false);
|
||||
FuriThread* main_thread = furi_thread_alloc_ex("Init", 4096, init_task, NULL);
|
||||
FuriThread* main_thread = furi_thread_alloc_ex("InitSrv", 1024, init_task, NULL);
|
||||
furi_thread_set_priority(main_thread, FuriThreadPriorityInit);
|
||||
|
||||
#ifdef FURI_RAM_EXEC
|
||||
// Prevent entering sleep mode when executed from RAM
|
||||
|
||||
@@ -3,7 +3,7 @@ ENTRY(Reset_Handler)
|
||||
/* Highest address of the user mode stack */
|
||||
_stack_end = 0x20030000; /* end of RAM */
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_stack_size = 0x1000; /* required amount of stack */
|
||||
_stack_size = 0x200; /* required amount of stack */
|
||||
|
||||
MEMORY {
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
|
||||
|
||||
@@ -3,7 +3,7 @@ ENTRY(Reset_Handler)
|
||||
/* Highest address of the user mode stack */
|
||||
_stack_end = 0x20030000; /* end of RAM */
|
||||
/* Generate a link error if heap and stack don't fit into RAM */
|
||||
_stack_size = 0x1000; /* required amount of stack */
|
||||
_stack_size = 0x200; /* required amount of stack */
|
||||
|
||||
MEMORY {
|
||||
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
|
||||
|
||||
Reference in New Issue
Block a user