Furi: core refactoring and CMSIS removal part 2 (#1410)
* Furi: rename and move core * Furi: drop CMSIS_OS header and unused api, partially refactor and cleanup the rest * Furi: CMSIS_OS drop and refactoring. * Furi: refactoring, remove cmsis legacy * Furi: fix incorrect assert on queue deallocation, cleanup timer * Furi: improve delay api, get rid of floats * hal: dropped furi_hal_crc * Furi: move DWT based delay to cortex HAL * Furi: update core documentation Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#include <ble.h>
|
||||
#include <stm32wbxx.h>
|
||||
#include <shci.h>
|
||||
#include <cmsis_os2.h>
|
||||
|
||||
#include <furi_hal_version.h>
|
||||
#include <furi_hal_bt_hid.h>
|
||||
@@ -19,7 +18,7 @@
|
||||
/* Time, in ms, to wait for mode transition before crashing */
|
||||
#define C2_MODE_SWITCH_TIMEOUT 10000
|
||||
|
||||
osMutexId_t furi_hal_bt_core2_mtx = NULL;
|
||||
FuriMutex* furi_hal_bt_core2_mtx = NULL;
|
||||
static FuriHalBtStack furi_hal_bt_stack = FuriHalBtStackUnknown;
|
||||
|
||||
typedef void (*FuriHalBtProfileStart)(void);
|
||||
@@ -79,7 +78,7 @@ FuriHalBtProfileConfig* current_profile = NULL;
|
||||
|
||||
void furi_hal_bt_init() {
|
||||
if(!furi_hal_bt_core2_mtx) {
|
||||
furi_hal_bt_core2_mtx = osMutexNew(NULL);
|
||||
furi_hal_bt_core2_mtx = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
furi_assert(furi_hal_bt_core2_mtx);
|
||||
}
|
||||
|
||||
@@ -94,12 +93,12 @@ void furi_hal_bt_init() {
|
||||
|
||||
void furi_hal_bt_lock_core2() {
|
||||
furi_assert(furi_hal_bt_core2_mtx);
|
||||
furi_check(osMutexAcquire(furi_hal_bt_core2_mtx, osWaitForever) == osOK);
|
||||
furi_check(furi_mutex_acquire(furi_hal_bt_core2_mtx, FuriWaitForever) == FuriStatusOk);
|
||||
}
|
||||
|
||||
void furi_hal_bt_unlock_core2() {
|
||||
furi_assert(furi_hal_bt_core2_mtx);
|
||||
furi_check(osMutexRelease(furi_hal_bt_core2_mtx) == osOK);
|
||||
furi_check(furi_mutex_release(furi_hal_bt_core2_mtx) == FuriStatusOk);
|
||||
}
|
||||
|
||||
static bool furi_hal_bt_radio_stack_is_supported(const BleGlueC2Info* info) {
|
||||
@@ -126,7 +125,7 @@ bool furi_hal_bt_start_radio_stack() {
|
||||
bool res = false;
|
||||
furi_assert(furi_hal_bt_core2_mtx);
|
||||
|
||||
osMutexAcquire(furi_hal_bt_core2_mtx, osWaitForever);
|
||||
furi_mutex_acquire(furi_hal_bt_core2_mtx, FuriWaitForever);
|
||||
|
||||
// Explicitly tell that we are in charge of CLK48 domain
|
||||
if(!LL_HSEM_IsSemaphoreLocked(HSEM, CFG_HW_CLK48_CONFIG_SEMID)) {
|
||||
@@ -162,7 +161,7 @@ bool furi_hal_bt_start_radio_stack() {
|
||||
}
|
||||
res = true;
|
||||
} while(false);
|
||||
osMutexRelease(furi_hal_bt_core2_mtx);
|
||||
furi_mutex_release(furi_hal_bt_core2_mtx);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -255,7 +254,7 @@ void furi_hal_bt_reinit() {
|
||||
FURI_LOG_I(TAG, "Reset SHCI");
|
||||
furi_check(ble_glue_reinit_c2());
|
||||
|
||||
osDelay(100);
|
||||
furi_delay_ms(100);
|
||||
ble_glue_thread_stop();
|
||||
|
||||
FURI_LOG_I(TAG, "Start BT initialization");
|
||||
@@ -292,7 +291,7 @@ void furi_hal_bt_stop_advertising() {
|
||||
if(furi_hal_bt_is_active()) {
|
||||
gap_stop_advertising();
|
||||
while(furi_hal_bt_is_active()) {
|
||||
osDelay(1);
|
||||
furi_delay_tick(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -436,7 +435,7 @@ bool furi_hal_bt_ensure_c2_mode(BleGlueC2Mode mode) {
|
||||
return true;
|
||||
} else if(fw_start_res == BleGlueCommandResultRestartPending) {
|
||||
// Do nothing and wait for system reset
|
||||
osDelay(C2_MODE_SWITCH_TIMEOUT);
|
||||
furi_delay_ms(C2_MODE_SWITCH_TIMEOUT);
|
||||
furi_crash("Waiting for FUS->radio stack transition");
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user