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