2021-02-12 17:24:34 +00:00
|
|
|
#include "flipper.h"
|
|
|
|
#include <applications.h>
|
|
|
|
#include <furi.h>
|
2022-01-05 16:10:18 +00:00
|
|
|
#include <furi_hal_version.h>
|
2022-08-27 04:25:47 +00:00
|
|
|
#include <furi_hal_memory.h>
|
2023-02-26 15:15:26 +00:00
|
|
|
#include <furi_hal_rtc.h>
|
2021-04-19 16:30:25 +00:00
|
|
|
|
2023-11-01 07:24:11 +00:00
|
|
|
#include <FreeRTOS.h>
|
|
|
|
|
2021-11-12 13:04:35 +00:00
|
|
|
#define TAG "Flipper"
|
|
|
|
|
2021-04-30 11:20:33 +00:00
|
|
|
static void flipper_print_version(const char* target, const Version* version) {
|
2021-04-19 16:30:25 +00:00
|
|
|
if(version) {
|
2021-04-30 11:20:33 +00:00
|
|
|
FURI_LOG_I(
|
2021-11-12 13:04:35 +00:00
|
|
|
TAG,
|
2021-04-30 11:20:33 +00:00
|
|
|
"\r\n\t%s version:\t%s\r\n"
|
|
|
|
"\tBuild date:\t\t%s\r\n"
|
2022-04-13 20:50:25 +00:00
|
|
|
"\tGit Commit:\t\t%s (%s)%s\r\n"
|
2021-04-30 11:20:33 +00:00
|
|
|
"\tGit Branch:\t\t%s",
|
|
|
|
target,
|
|
|
|
version_get_version(version),
|
|
|
|
version_get_builddate(version),
|
2021-04-19 16:30:25 +00:00
|
|
|
version_get_githash(version),
|
2021-04-30 11:20:33 +00:00
|
|
|
version_get_gitbranchnum(version),
|
2022-04-13 20:50:25 +00:00
|
|
|
version_get_dirty_flag(version) ? " (dirty)" : "",
|
2021-04-30 11:20:33 +00:00
|
|
|
version_get_gitbranch(version));
|
2021-04-19 16:30:25 +00:00
|
|
|
} else {
|
2021-11-12 13:04:35 +00:00
|
|
|
FURI_LOG_I(TAG, "No build info for %s", target);
|
2021-04-19 16:30:25 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-12 17:24:34 +00:00
|
|
|
|
|
|
|
void flipper_init() {
|
2022-04-13 20:50:25 +00:00
|
|
|
flipper_print_version("Firmware", furi_hal_version_get_firmware_version());
|
2021-02-12 17:24:34 +00:00
|
|
|
|
2023-02-26 15:15:26 +00:00
|
|
|
FURI_LOG_I(TAG, "Boot mode %d, starting services", furi_hal_rtc_get_boot_mode());
|
2021-02-12 17:24:34 +00:00
|
|
|
|
|
|
|
for(size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) {
|
2023-03-14 14:29:28 +00:00
|
|
|
FURI_LOG_D(TAG, "Starting service %s", FLIPPER_SERVICES[i].name);
|
2021-02-12 17:24:34 +00:00
|
|
|
|
2022-11-23 12:49:17 +00:00
|
|
|
FuriThread* thread = furi_thread_alloc_ex(
|
|
|
|
FLIPPER_SERVICES[i].name,
|
|
|
|
FLIPPER_SERVICES[i].stack_size,
|
|
|
|
FLIPPER_SERVICES[i].app,
|
|
|
|
NULL);
|
2022-08-27 04:25:47 +00:00
|
|
|
furi_thread_mark_as_service(thread);
|
2023-03-01 17:57:27 +00:00
|
|
|
furi_thread_set_appid(thread, FLIPPER_SERVICES[i].appid);
|
2021-02-12 17:24:34 +00:00
|
|
|
|
|
|
|
furi_thread_start(thread);
|
|
|
|
}
|
|
|
|
|
2023-02-26 15:15:26 +00:00
|
|
|
FURI_LOG_I(TAG, "Startup complete");
|
2021-04-19 16:30:25 +00:00
|
|
|
}
|
2022-08-27 04:25:47 +00:00
|
|
|
|
|
|
|
void vApplicationGetIdleTaskMemory(
|
|
|
|
StaticTask_t** tcb_ptr,
|
|
|
|
StackType_t** stack_ptr,
|
|
|
|
uint32_t* stack_size) {
|
|
|
|
*tcb_ptr = memmgr_alloc_from_pool(sizeof(StaticTask_t));
|
2023-03-28 07:34:49 +00:00
|
|
|
*stack_ptr = memmgr_alloc_from_pool(sizeof(StackType_t) * configIDLE_TASK_STACK_DEPTH);
|
|
|
|
*stack_size = configIDLE_TASK_STACK_DEPTH;
|
2022-08-27 04:25:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|