1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 04:34:43 +04:00

Merge remote-tracking branch 'OFW/dev' into dev

This commit is contained in:
MX
2024-10-14 16:50:56 +03:00
27 changed files with 523 additions and 330 deletions

View File

@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,76.0,,
Version,+,77.0,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
Header,+,applications/services/cli/cli.h,,
@@ -1102,6 +1102,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
@@ -1672,6 +1673,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_expire_time,uint32_t,FuriTimer*
Function,+,furi_timer_is_running,uint32_t,FuriTimer*
1 entry status name type params
2 Version + 76.0 77.0
3 Header + applications/services/bt/bt_service/bt.h
4 Header + applications/services/bt/bt_service/bt_keys_storage.h
5 Header + applications/services/cli/cli.h
1102 Function - ftrylockfile int FILE*
1103 Function - funlockfile void FILE*
1104 Function - funopen FILE* const void*, int (*)(void*, char*, int), int (*)(void*, const char*, int), fpos_t (*)(void*, fpos_t, int), int (*)(void*)
1105 Function - furi_background void
1106 Function + furi_delay_ms void uint32_t
1107 Function + furi_delay_tick void uint32_t
1108 Function + furi_delay_until_tick FuriStatus uint32_t
1673 Function + furi_thread_suspend void FuriThreadId
1674 Function + furi_thread_yield void
1675 Function + furi_timer_alloc FuriTimer* FuriTimerCallback, FuriTimerType, void*
1676 Function + furi_timer_flush void
1677 Function + furi_timer_free void FuriTimer*
1678 Function + furi_timer_get_expire_time uint32_t FuriTimer*
1679 Function + furi_timer_is_running uint32_t FuriTimer*

View File

@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,76.0,,
Version,+,77.0,,
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
@@ -1243,6 +1243,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
@@ -1936,6 +1937,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_expire_time,uint32_t,FuriTimer*
Function,+,furi_timer_is_running,uint32_t,FuriTimer*
1 entry status name type params
2 Version + 76.0 77.0
3 Header + applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h
4 Header + applications/services/bt/bt_service/bt.h
5 Header + applications/services/bt/bt_service/bt_keys_storage.h
1243 Function - ftrylockfile int FILE*
1244 Function - funlockfile void FILE*
1245 Function - funopen FILE* const void*, int (*)(void*, char*, int), int (*)(void*, const char*, int), fpos_t (*)(void*, fpos_t, int), int (*)(void*)
1246 Function - furi_background void
1247 Function + furi_delay_ms void uint32_t
1248 Function + furi_delay_tick void uint32_t
1249 Function + furi_delay_until_tick FuriStatus uint32_t
1937 Function + furi_thread_suspend void FuriThreadId
1938 Function + furi_thread_yield void
1939 Function + furi_timer_alloc FuriTimer* FuriTimerCallback, FuriTimerType, void*
1940 Function + furi_timer_flush void
1941 Function + furi_timer_free void FuriTimer*
1942 Function + furi_timer_get_expire_time uint32_t FuriTimer*
1943 Function + furi_timer_is_running uint32_t FuriTimer*

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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>

View File

@@ -15,6 +15,8 @@ int32_t init_task(void* context) {
// Init flipper
flipper_init();
furi_background();
return 0;
}
@@ -25,7 +27,8 @@ int main(void) {
// Flipper critical FURI HAL
furi_hal_init_early();
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