| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- #include "App_freertosTask.h"
- #include <stdio.h>
- #include "lvgl.h"
- #include "lv_port_disp.h"
- #include "lv_port_indev.h"
- #include "Int_gt1151.h"
- #include "Ui.h"
- #include "Com_usb_cdc.h"
- #define TASK_CPLD_PRIORITY 4
- #define TASK_CPLD_STACK_SIZE 512
- #define TASK_LVGL_PRIORITY 3
- #define TASK_LVGL_STACK_SIZE 2048
- #define TASK_TEST_PRIORITY 1
- #define TASK_TEST_STACK_SIZE 512
- TaskHandle_t xCPLDProcessTaskHandle = NULL;
- TaskHandle_t xLVGLDisplayTaskHandle = NULL;
- TaskHandle_t xTestTaskHandle = NULL;
- /**
- * @brief 创建各个任务
- *
- */
- void App_Task_Create(void)
- {
- BaseType_t ret;
- Com_usb_cdc_init();
- ret = xTaskCreate(Task_CPLD_Process, "cpldProcessTask", TASK_CPLD_STACK_SIZE, NULL, TASK_CPLD_PRIORITY, &xCPLDProcessTaskHandle);
- if (ret != pdPASS)
- {
- printf("[ERR] CPLD process task create failed\r\n");
- }
- ret = xTaskCreate(Task_LVGL_Display, "lvglDisplayTask", TASK_LVGL_STACK_SIZE, NULL, TASK_LVGL_PRIORITY, &xLVGLDisplayTaskHandle);
- if (ret != pdPASS)
- {
- printf("[ERR] LVGL display task create failed\r\n");
- }
- ret = xTaskCreate(Task_Test, "testTask", TASK_TEST_STACK_SIZE, NULL, TASK_TEST_PRIORITY, &xTestTaskHandle);
- if (ret != pdPASS)
- {
- printf("[ERR] Test task create failed\r\n");
- }
- }
- /**
- * @brief 处理 CPLD 通信的任务
- *
- * @param argument
- */
- void Task_CPLD_Process(void *argument)
- {
- (void)argument;
- printf("CPLD process task running...\r\n");
- while (1)
- {
- /* TODO: CPLD 通信处理 */
- vTaskDelay(pdMS_TO_TICKS(1000));
- }
- }
- /**
- * @brief 处理 LVGL 显示的任务
- *
- * @param argument
- */
- void Task_LVGL_Display(void *argument)
- {
- (void)argument;
- printf("LVGL display task running...\r\n");
- /* LVGL 内核初始化 */
- lv_init();
- /* 注册显示驱动:LTDC + SDRAM 静态显存 + 双全屏缓冲 */
- lv_port_disp_init();
- /* 初始化 GT1151Q 电容触摸芯片 */
- if (Int_gt1151_init() == 0)
- {
- printf("GT1151 Init OK\r\n");
- /* 注册触摸输入设备 (注意: 需在 lv_init 之后、主循环 lv_timer_handler 之前) */
- lv_port_indev_init();
- }
- else
- {
- printf("[ERR] GT1151 Init failed\r\n");
- }
- /* 创建工业设备主页 (UI 页面层) */
- Ui_init();
- /* 假数据: 设备就绪 */
- Ui_set_ready(true);
- while (1)
- {
- /* 周期驱动 LVGL(渲染/动画/输入),配合 LV_DISP_DEF_REFR_PERIOD 30ms */
- lv_timer_handler();
- vTaskDelay(pdMS_TO_TICKS(5));
- }
- }
- /**
- * @brief 处理测试的任务
- *
- * @param argument
- */
- void Task_Test(void *argument)
- {
- (void)argument;
- printf("Test task running...\r\n");
- while (1)
- {
- /* TODO: 测试 */
- vTaskDelay(pdMS_TO_TICKS(5000));
- }
- }
|