App_freertosTask.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #include "App_freertosTask.h"
  2. #include <stdio.h>
  3. #define TASK_CPLD_PRIORITY 4
  4. #define TASK_CPLD_STACK_SIZE 512
  5. #define TASK_LVGL_PRIORITY 3
  6. #define TASK_LVGL_STACK_SIZE 1024
  7. #define TASK_TEST_PRIORITY 1
  8. #define TASK_TEST_STACK_SIZE 512
  9. TaskHandle_t xCPLDProcessTaskHandle = NULL;
  10. TaskHandle_t xLVGLDisplayTaskHandle = NULL;
  11. TaskHandle_t xTestTaskHandle = NULL;
  12. /**
  13. * @brief 创建各个任务
  14. *
  15. */
  16. void App_Task_Create(void)
  17. {
  18. BaseType_t ret;
  19. ret = xTaskCreate(Task_CPLD_Process, "cpldProcessTask", TASK_CPLD_STACK_SIZE, NULL, TASK_CPLD_PRIORITY, &xCPLDProcessTaskHandle);
  20. if (ret != pdPASS)
  21. {
  22. printf("[ERR] CPLD process task create failed\r\n");
  23. }
  24. ret = xTaskCreate(Task_LVGL_Display, "lvglDisplayTask", TASK_LVGL_STACK_SIZE, NULL, TASK_LVGL_PRIORITY, &xLVGLDisplayTaskHandle);
  25. if (ret != pdPASS)
  26. {
  27. printf("[ERR] LVGL display task create failed\r\n");
  28. }
  29. ret = xTaskCreate(Task_Test, "testTask", TASK_TEST_STACK_SIZE, NULL, TASK_TEST_PRIORITY, &xTestTaskHandle);
  30. if (ret != pdPASS)
  31. {
  32. printf("[ERR] Test task create failed\r\n");
  33. }
  34. }
  35. /**
  36. * @brief 处理 CPLD 通信的任务
  37. *
  38. * @param argument
  39. */
  40. void Task_CPLD_Process(void *argument)
  41. {
  42. (void)argument;
  43. printf("CPLD process task running...\r\n");
  44. while (1)
  45. {
  46. printf("CPLD\r\n");
  47. /* TODO: CPLD 通信处理 */
  48. vTaskDelay(pdMS_TO_TICKS(1000));
  49. }
  50. }
  51. /**
  52. * @brief 处理 LVGL 显示的任务
  53. *
  54. * @param argument
  55. */
  56. void Task_LVGL_Display(void *argument)
  57. {
  58. (void)argument;
  59. printf("LVGL display task running...\r\n");
  60. while (1)
  61. {
  62. printf("LVGL\r\n");
  63. /* TODO: LVGL 显示 */
  64. vTaskDelay(pdMS_TO_TICKS(3000));
  65. }
  66. }
  67. /**
  68. * @brief 处理测试的任务
  69. *
  70. * @param argument
  71. */
  72. void Task_Test(void *argument)
  73. {
  74. (void)argument;
  75. printf("Test task running...\r\n");
  76. while (1)
  77. {
  78. printf("TEST\r\n");
  79. /* TODO: 测试 */
  80. vTaskDelay(pdMS_TO_TICKS(5000));
  81. }
  82. }