flipper.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "flipper.h"
  2. #include <applications.h>
  3. #include <furi.h>
  4. #include <furi_hal_version.h>
  5. #include <furi_hal_memory.h>
  6. #include <furi_hal_rtc.h>
  7. #define TAG "Flipper"
  8. static void flipper_print_version(const char* target, const Version* version) {
  9. if(version) {
  10. FURI_LOG_I(
  11. TAG,
  12. "\r\n\t%s version:\t%s\r\n"
  13. "\tBuild date:\t\t%s\r\n"
  14. "\tGit Commit:\t\t%s (%s)%s\r\n"
  15. "\tGit Branch:\t\t%s",
  16. target,
  17. version_get_version(version),
  18. version_get_builddate(version),
  19. version_get_githash(version),
  20. version_get_gitbranchnum(version),
  21. version_get_dirty_flag(version) ? " (dirty)" : "",
  22. version_get_gitbranch(version));
  23. } else {
  24. FURI_LOG_I(TAG, "No build info for %s", target);
  25. }
  26. }
  27. void flipper_init() {
  28. flipper_print_version("Firmware", furi_hal_version_get_firmware_version());
  29. FURI_LOG_I(TAG, "Boot mode %d, starting services", furi_hal_rtc_get_boot_mode());
  30. for(size_t i = 0; i < FLIPPER_SERVICES_COUNT; i++) {
  31. FURI_LOG_I(TAG, "Starting service %s", FLIPPER_SERVICES[i].name);
  32. FuriThread* thread = furi_thread_alloc_ex(
  33. FLIPPER_SERVICES[i].name,
  34. FLIPPER_SERVICES[i].stack_size,
  35. FLIPPER_SERVICES[i].app,
  36. NULL);
  37. furi_thread_mark_as_service(thread);
  38. furi_thread_set_appid(thread, FLIPPER_SERVICES[i].appid);
  39. furi_thread_start(thread);
  40. }
  41. FURI_LOG_I(TAG, "Startup complete");
  42. }
  43. void vApplicationGetIdleTaskMemory(
  44. StaticTask_t** tcb_ptr,
  45. StackType_t** stack_ptr,
  46. uint32_t* stack_size) {
  47. *tcb_ptr = memmgr_alloc_from_pool(sizeof(StaticTask_t));
  48. *stack_ptr = memmgr_alloc_from_pool(sizeof(StackType_t) * configMINIMAL_STACK_SIZE);
  49. *stack_size = configMINIMAL_STACK_SIZE;
  50. }
  51. void vApplicationGetTimerTaskMemory(
  52. StaticTask_t** tcb_ptr,
  53. StackType_t** stack_ptr,
  54. uint32_t* stack_size) {
  55. *tcb_ptr = memmgr_alloc_from_pool(sizeof(StaticTask_t));
  56. *stack_ptr = memmgr_alloc_from_pool(sizeof(StackType_t) * configTIMER_TASK_STACK_DEPTH);
  57. *stack_size = configTIMER_TASK_STACK_DEPTH;
  58. }