[FL-2591] Furi: remove CMSIS thread api, migrate to FuriThread, remove unused CMSIS APIs (#1333)
* Furi: remove CMSIS thread api, migrate to FuriThread, remove unused CMSIS APIs * Furi: magic thread catcher validating thread completion; backtrace improver * Furi: allow furi_thread_get_current_id outside of thread context * Furi: use IRQ instead of ISR for core primitives
This commit is contained in:
@@ -19,7 +19,7 @@ ViewPort* gui_view_port_find_enabled(ViewPortArray_t array) {
|
||||
|
||||
void gui_update(Gui* gui) {
|
||||
furi_assert(gui);
|
||||
osThreadFlagsSet(gui->thread, GUI_THREAD_FLAG_DRAW);
|
||||
furi_thread_flags_set(gui->thread_id, GUI_THREAD_FLAG_DRAW);
|
||||
}
|
||||
|
||||
void gui_input_events_callback(const void* value, void* ctx) {
|
||||
@@ -29,7 +29,7 @@ void gui_input_events_callback(const void* value, void* ctx) {
|
||||
Gui* gui = ctx;
|
||||
|
||||
osMessageQueuePut(gui->input_queue, value, 0, osWaitForever);
|
||||
osThreadFlagsSet(gui->thread, GUI_THREAD_FLAG_INPUT);
|
||||
furi_thread_flags_set(gui->thread_id, GUI_THREAD_FLAG_INPUT);
|
||||
}
|
||||
|
||||
// Only Fullscreen supports vertical display for now
|
||||
@@ -471,7 +471,7 @@ void gui_set_lockdown(Gui* gui, bool lockdown) {
|
||||
Gui* gui_alloc() {
|
||||
Gui* gui = malloc(sizeof(Gui));
|
||||
// Thread ID
|
||||
gui->thread = osThreadGetId();
|
||||
gui->thread_id = furi_thread_get_current_id();
|
||||
// Allocate mutex
|
||||
gui->mutex = osMutexNew(NULL);
|
||||
furi_check(gui->mutex);
|
||||
@@ -500,7 +500,8 @@ int32_t gui_srv(void* p) {
|
||||
furi_record_create("gui", gui);
|
||||
|
||||
while(1) {
|
||||
uint32_t flags = osThreadFlagsWait(GUI_THREAD_FLAG_ALL, osFlagsWaitAny, osWaitForever);
|
||||
uint32_t flags =
|
||||
furi_thread_flags_wait(GUI_THREAD_FLAG_ALL, osFlagsWaitAny, osWaitForever);
|
||||
// Process and dispatch input
|
||||
if(flags & GUI_THREAD_FLAG_INPUT) {
|
||||
// Process till queue become empty
|
||||
@@ -512,7 +513,7 @@ int32_t gui_srv(void* p) {
|
||||
// Process and dispatch draw call
|
||||
if(flags & GUI_THREAD_FLAG_DRAW) {
|
||||
// Clear flags that arrived on input step
|
||||
osThreadFlagsClear(GUI_THREAD_FLAG_DRAW);
|
||||
furi_thread_flags_clear(GUI_THREAD_FLAG_DRAW);
|
||||
gui_redraw(gui);
|
||||
}
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ ALGO_DEF(CanvasCallbackPairArray, CanvasCallbackPairArray_t);
|
||||
/** Gui structure */
|
||||
struct Gui {
|
||||
// Thread and lock
|
||||
osThreadId_t thread;
|
||||
FuriThreadId thread_id;
|
||||
osMutexId_t mutex;
|
||||
|
||||
// Layers and Canvas
|
||||
|
@@ -259,10 +259,10 @@ static int32_t browser_worker(void* context) {
|
||||
string_t filename;
|
||||
string_init(filename);
|
||||
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(browser->thread), WorkerEvtConfigChange);
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtConfigChange);
|
||||
|
||||
while(1) {
|
||||
uint32_t flags = osThreadFlagsWait(WORKER_FLAGS_ALL, osFlagsWaitAny, osWaitForever);
|
||||
uint32_t flags = furi_thread_flags_wait(WORKER_FLAGS_ALL, osFlagsWaitAny, osWaitForever);
|
||||
furi_assert((flags & osFlagsError) == 0);
|
||||
|
||||
if(flags & WorkerEvtConfigChange) {
|
||||
@@ -272,7 +272,7 @@ static int32_t browser_worker(void* context) {
|
||||
}
|
||||
idx_last_array_reset(browser->idx_last);
|
||||
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(browser->thread), WorkerEvtFolderEnter);
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtFolderEnter);
|
||||
}
|
||||
|
||||
if(flags & WorkerEvtFolderEnter) {
|
||||
@@ -369,7 +369,7 @@ BrowserWorker* file_browser_worker_alloc(string_t path, const char* filter_ext,
|
||||
void file_browser_worker_free(BrowserWorker* browser) {
|
||||
furi_assert(browser);
|
||||
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(browser->thread), WorkerEvtStop);
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtStop);
|
||||
furi_thread_join(browser->thread);
|
||||
furi_thread_free(browser->thread);
|
||||
|
||||
@@ -423,30 +423,30 @@ void file_browser_worker_set_config(
|
||||
string_set(browser->path_next, path);
|
||||
string_set_str(browser->filter_extension, filter_ext);
|
||||
browser->skip_assets = skip_assets;
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(browser->thread), WorkerEvtConfigChange);
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtConfigChange);
|
||||
}
|
||||
|
||||
void file_browser_worker_folder_enter(BrowserWorker* browser, string_t path, int32_t item_idx) {
|
||||
furi_assert(browser);
|
||||
string_set(browser->path_next, path);
|
||||
browser->item_sel_idx = item_idx;
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(browser->thread), WorkerEvtFolderEnter);
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtFolderEnter);
|
||||
}
|
||||
|
||||
void file_browser_worker_folder_exit(BrowserWorker* browser) {
|
||||
furi_assert(browser);
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(browser->thread), WorkerEvtFolderExit);
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtFolderExit);
|
||||
}
|
||||
|
||||
void file_browser_worker_folder_refresh(BrowserWorker* browser, int32_t item_idx) {
|
||||
furi_assert(browser);
|
||||
browser->item_sel_idx = item_idx;
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(browser->thread), WorkerEvtFolderRefresh);
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtFolderRefresh);
|
||||
}
|
||||
|
||||
void file_browser_worker_load(BrowserWorker* browser, uint32_t offset, uint32_t count) {
|
||||
furi_assert(browser);
|
||||
browser->load_offset = offset;
|
||||
browser->load_count = count;
|
||||
osThreadFlagsSet(furi_thread_get_thread_id(browser->thread), WorkerEvtLoad);
|
||||
furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtLoad);
|
||||
}
|
||||
|
Reference in New Issue
Block a user