mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
Merge branch 'dev' into reborned/some_api_adjustments
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,74.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
|
||||
@@ -1652,7 +1653,6 @@ Function,+,furi_thread_list_free,void,FuriThreadList*
|
||||
Function,+,furi_thread_list_get_at,FuriThreadListItem*,"FuriThreadList*, size_t"
|
||||
Function,+,furi_thread_list_get_isr_time,float,FuriThreadList*
|
||||
Function,+,furi_thread_list_get_or_insert,FuriThreadListItem*,"FuriThreadList*, FuriThread*"
|
||||
Function,+,furi_thread_list_process,void,"FuriThreadList*, uint32_t, uint32_t"
|
||||
Function,+,furi_thread_list_size,size_t,FuriThreadList*
|
||||
Function,+,furi_thread_resume,void,FuriThreadId
|
||||
Function,+,furi_thread_set_appid,void,"FuriThread*, const char*"
|
||||
@@ -1673,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*
|
||||
|
||||
|
@@ -1208,6 +1208,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
|
||||
@@ -1867,7 +1868,6 @@ Function,+,furi_thread_list_free,void,FuriThreadList*
|
||||
Function,+,furi_thread_list_get_at,FuriThreadListItem*,"FuriThreadList*, size_t"
|
||||
Function,+,furi_thread_list_get_isr_time,float,FuriThreadList*
|
||||
Function,+,furi_thread_list_get_or_insert,FuriThreadListItem*,"FuriThreadList*, FuriThread*"
|
||||
Function,+,furi_thread_list_process,void,"FuriThreadList*, uint32_t, uint32_t"
|
||||
Function,+,furi_thread_list_size,size_t,FuriThreadList*
|
||||
Function,+,furi_thread_resume,void,FuriThreadId
|
||||
Function,+,furi_thread_set_appid,void,"FuriThread*, const char*"
|
||||
@@ -1888,6 +1888,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*
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
@@ -129,7 +129,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: {
|
||||
@@ -304,7 +304,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;
|
||||
}
|
||||
@@ -490,7 +490,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");
|
||||
@@ -498,18 +498,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_advetise_timer_callback(void* context) {
|
||||
@@ -566,9 +566,9 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
||||
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;
|
||||
}
|
||||
@@ -577,17 +577,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);
|
||||
@@ -604,7 +608,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;
|
||||
}
|
||||
@@ -615,7 +619,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;
|
||||
|
||||
@@ -73,18 +73,14 @@ void furi_hal_power_init(void) {
|
||||
// Find and init gauge
|
||||
size_t retry = 2;
|
||||
while(retry > 0) {
|
||||
furi_hal_power.gauge_ok = bq27220_init(&furi_hal_i2c_handle_power);
|
||||
if(furi_hal_power.gauge_ok) {
|
||||
furi_hal_power.gauge_ok = bq27220_apply_data_memory(
|
||||
&furi_hal_i2c_handle_power, furi_hal_power_gauge_data_memory);
|
||||
}
|
||||
furi_hal_power.gauge_ok =
|
||||
bq27220_init(&furi_hal_i2c_handle_power, furi_hal_power_gauge_data_memory);
|
||||
if(furi_hal_power.gauge_ok) {
|
||||
break;
|
||||
} else {
|
||||
// Normal startup time is 250ms
|
||||
// But if we try to access gauge at that stage it will become unresponsive
|
||||
// 2 seconds timeout needed to restart communication
|
||||
furi_delay_us(2020202);
|
||||
// Gauge need some time to think about it's behavior
|
||||
// We must wait, otherwise next init cycle will fail at unseal stage
|
||||
furi_delay_us(4000000);
|
||||
}
|
||||
retry--;
|
||||
}
|
||||
@@ -110,8 +106,8 @@ void furi_hal_power_init(void) {
|
||||
bool furi_hal_power_gauge_is_ok(void) {
|
||||
bool ret = true;
|
||||
|
||||
BatteryStatus battery_status;
|
||||
OperationStatus operation_status;
|
||||
Bq27220BatteryStatus battery_status;
|
||||
Bq27220OperationStatus operation_status;
|
||||
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
|
||||
@@ -132,7 +128,7 @@ bool furi_hal_power_gauge_is_ok(void) {
|
||||
bool furi_hal_power_is_shutdown_requested(void) {
|
||||
bool ret = false;
|
||||
|
||||
BatteryStatus battery_status;
|
||||
Bq27220BatteryStatus battery_status;
|
||||
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
|
||||
@@ -593,8 +589,8 @@ void furi_hal_power_debug_get(PropertyValueCallback out, void* context) {
|
||||
PropertyValueContext property_context = {
|
||||
.key = key, .value = value, .out = out, .sep = '.', .last = false, .context = context};
|
||||
|
||||
BatteryStatus battery_status;
|
||||
OperationStatus operation_status;
|
||||
Bq27220BatteryStatus battery_status;
|
||||
Bq27220OperationStatus operation_status;
|
||||
|
||||
furi_hal_i2c_acquire(&furi_hal_i2c_handle_power);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#define TAG "FuriHalRandom"
|
||||
|
||||
static uint32_t furi_hal_random_read_rng(void) {
|
||||
while(LL_RNG_IsActiveFlag_CECS(RNG) && LL_RNG_IsActiveFlag_SECS(RNG) &&
|
||||
while(LL_RNG_IsActiveFlag_CECS(RNG) || LL_RNG_IsActiveFlag_SECS(RNG) ||
|
||||
!LL_RNG_IsActiveFlag_DRDY(RNG)) {
|
||||
/* Error handling as described in RM0434, pg. 582-583 */
|
||||
if(LL_RNG_IsActiveFlag_CECS(RNG)) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user