flipper.c 2.0 KB

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