Core: thread allocation shortcut (#2007)

* Core: thread alloc+set shortcut
* Apps: use thread allocation shortcut
* Mark some service threads as services
* Init BT as soon as possible

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Sergey Gavrilov
2022-11-23 22:49:17 +10:00
committed by GitHub
parent b9c483fbf8
commit c511c67e71
38 changed files with 94 additions and 195 deletions

View File

@@ -26,10 +26,7 @@ int main() {
// Flipper critical FURI HAL
furi_hal_init_early();
FuriThread* main_thread = furi_thread_alloc();
furi_thread_set_name(main_thread, "Init");
furi_thread_set_stack_size(main_thread, 4096);
furi_thread_set_callback(main_thread, init_task);
FuriThread* main_thread = furi_thread_alloc_ex("Init", 4096, init_task, NULL);
#ifdef FURI_RAM_EXEC
furi_thread_start(main_thread);

View File

@@ -1471,6 +1471,7 @@ Function,+,furi_string_utf8_length,size_t,FuriString*
Function,+,furi_string_utf8_push,void,"FuriString*, FuriStringUnicodeValue"
Function,+,furi_string_vprintf,int,"FuriString*, const char[], va_list"
Function,+,furi_thread_alloc,FuriThread*,
Function,+,furi_thread_alloc_ex,FuriThread*,"const char*, uint32_t, FuriThreadCallback, void*"
Function,+,furi_thread_catch,void,
Function,-,furi_thread_disable_heap_trace,void,FuriThread*
Function,+,furi_thread_enable_heap_trace,void,FuriThread*
1 entry status name type params
1471 Function + furi_string_utf8_push void FuriString*, FuriStringUnicodeValue
1472 Function + furi_string_vprintf int FuriString*, const char[], va_list
1473 Function + furi_thread_alloc FuriThread*
1474 Function + furi_thread_alloc_ex FuriThread* const char*, uint32_t, FuriThreadCallback, void*
1475 Function + furi_thread_catch void
1476 Function - furi_thread_disable_heap_trace void FuriThread*
1477 Function + furi_thread_enable_heap_trace void FuriThread*

View File

@@ -40,11 +40,7 @@ bool ble_app_init() {
ble_app->hci_mtx = furi_mutex_alloc(FuriMutexTypeNormal);
ble_app->hci_sem = furi_semaphore_alloc(1, 0);
// HCI transport layer thread to handle user asynch events
ble_app->thread = furi_thread_alloc();
furi_thread_set_name(ble_app->thread, "BleHciDriver");
furi_thread_set_stack_size(ble_app->thread, 1024);
furi_thread_set_context(ble_app->thread, ble_app);
furi_thread_set_callback(ble_app->thread, ble_app_hci_thread);
ble_app->thread = furi_thread_alloc_ex("BleHciDriver", 1024, ble_app_hci_thread, ble_app);
furi_thread_start(ble_app->thread);
// Initialize Ble Transport Layer

View File

@@ -78,11 +78,7 @@ void ble_glue_init() {
ble_glue->shci_sem = furi_semaphore_alloc(1, 0);
// FreeRTOS system task creation
ble_glue->thread = furi_thread_alloc();
furi_thread_set_name(ble_glue->thread, "BleShciDriver");
furi_thread_set_stack_size(ble_glue->thread, 1024);
furi_thread_set_context(ble_glue->thread, ble_glue);
furi_thread_set_callback(ble_glue->thread, ble_glue_shci_thread);
ble_glue->thread = furi_thread_alloc_ex("BleShciDriver", 1024, ble_glue_shci_thread, ble_glue);
furi_thread_start(ble_glue->thread);
// System channel initialization

View File

@@ -492,11 +492,7 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
gap->enable_adv = true;
// Thread configuration
gap->thread = furi_thread_alloc();
furi_thread_set_name(gap->thread, "BleGapDriver");
furi_thread_set_stack_size(gap->thread, 1024);
furi_thread_set_context(gap->thread, gap);
furi_thread_set_callback(gap->thread, gap_app);
gap->thread = furi_thread_alloc_ex("BleGapDriver", 1024, gap_app, gap);
furi_thread_start(gap->thread);
// Command queue allocation

View File

@@ -61,26 +61,25 @@ void furi_hal_init() {
furi_hal_crypto_init();
// USB
#ifndef FURI_RAM_EXEC
furi_hal_usb_init();
FURI_LOG_I(TAG, "USB OK");
#endif
furi_hal_i2c_init();
// High Level
furi_hal_power_init();
furi_hal_light_init();
furi_hal_bt_init();
furi_hal_memory_init();
furi_hal_compress_icon_init();
#ifndef FURI_RAM_EXEC
// USB
furi_hal_usb_init();
FURI_LOG_I(TAG, "USB OK");
furi_hal_vibro_init();
furi_hal_subghz_init();
furi_hal_nfc_init();
furi_hal_rfid_init();
#endif
furi_hal_bt_init();
furi_hal_memory_init();
furi_hal_compress_icon_init();
// FatFS driver initialization
MX_FATFS_Init();

View File

@@ -80,10 +80,8 @@ void furi_hal_usb_init(void) {
NVIC_EnableIRQ(USB_LP_IRQn);
NVIC_EnableIRQ(USB_HP_IRQn);
usb.thread = furi_thread_alloc();
furi_thread_set_name(usb.thread, "UsbDriver");
furi_thread_set_stack_size(usb.thread, 1024);
furi_thread_set_callback(usb.thread, furi_hal_usb_thread);
usb.thread = furi_thread_alloc_ex("UsbDriver", 1024, furi_hal_usb_thread, NULL);
furi_thread_mark_as_service(usb.thread);
furi_thread_start(usb.thread);
FURI_LOG_I(TAG, "Init OK");