unleashed-firmware/furi/flipper.c
Georgii Surkov 20c4121f25
[FL-3832] Use static synchronisation primitives (#3679)
* Use static mutex
* Add static_assert checks
* Use static semaphore
* Fix formatting
* Use static stream buffer
* Use static timer
* Use static event group
* Increase allocation size for stream buffer
* Remove recursive bit from the mutex before freeing
* Prevent service tasks from ever returning
* Use static threads
* Do not realloc memory when changing stack size
* Use FuriSemaphore instead of raw FreeRTOS one in rpc_test
* Remove redundant includes
* Abolish FreeRTOS dynamic allocation
* Improve FuriMutex
* Improve FuriMessageQueue
* Remove redundant comments and parentheses
* Clean up code more
* Create service threads via a dedicated constructor
* Minor code improvements
* Update docs for FuriThread, FuriTimer
* Fix doxygen typo
* Use a bigger buffer for static StreamBuffer
* Furi: remove timer control block only when timer thread have completed all operations
---------

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2024-06-05 18:04:03 +01:00

69 lines
2.1 KiB
C

#include "flipper.h"
#include <applications.h>
#include <furi.h>
#include <furi_hal_version.h>
#include <furi_hal_memory.h>
#include <furi_hal_rtc.h>
#include <FreeRTOS.h>
#define TAG "Flipper"
static void flipper_print_version(const char* target, const Version* version) {
if(version) {
FURI_LOG_I(
TAG,
"\r\n\t%s version:\t%s\r\n"
"\tBuild date:\t\t%s\r\n"
"\tGit Commit:\t\t%s (%s)%s\r\n"
"\tGit Branch:\t\t%s",
target,
version_get_version(version),
version_get_builddate(version),
version_get_githash(version),
version_get_gitbranchnum(version),
version_get_dirty_flag(version) ? " (dirty)" : "",
version_get_gitbranch(version));
} else {
FURI_LOG_I(TAG, "No build info for %s", target);
}
}
void flipper_init(void) {
flipper_print_version("Firmware", furi_hal_version_get_firmware_version());
FURI_LOG_I(TAG, "Boot mode %d, starting services", furi_hal_rtc_get_boot_mode());
for(size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) {
FURI_LOG_D(TAG, "Starting service %s", FLIPPER_SERVICES[i].name);
FuriThread* thread = furi_thread_alloc_service(
FLIPPER_SERVICES[i].name,
FLIPPER_SERVICES[i].stack_size,
FLIPPER_SERVICES[i].app,
NULL);
furi_thread_set_appid(thread, FLIPPER_SERVICES[i].appid);
furi_thread_start(thread);
}
FURI_LOG_I(TAG, "Startup complete");
}
void vApplicationGetIdleTaskMemory(
StaticTask_t** tcb_ptr,
StackType_t** stack_ptr,
uint32_t* stack_size) {
*tcb_ptr = memmgr_alloc_from_pool(sizeof(StaticTask_t));
*stack_ptr = memmgr_alloc_from_pool(sizeof(StackType_t) * configIDLE_TASK_STACK_DEPTH);
*stack_size = configIDLE_TASK_STACK_DEPTH;
}
void vApplicationGetTimerTaskMemory(
StaticTask_t** tcb_ptr,
StackType_t** stack_ptr,
uint32_t* stack_size) {
*tcb_ptr = memmgr_alloc_from_pool(sizeof(StaticTask_t));
*stack_ptr = memmgr_alloc_from_pool(sizeof(StackType_t) * configTIMER_TASK_STACK_DEPTH);
*stack_size = configTIMER_TASK_STACK_DEPTH;
}