Files
Power-Pico/Power_Pico/User/Tasks/Src/user_TasksInit.c

129 lines
2.8 KiB
C

/* Private includes -----------------------------------------------------------*/
//includes
#include "user_TasksInit.h"
//sys
#include "sys.h"
#include "stdio.h"
//gui
#include "lvgl.h"
//tasks
#include "user_HardwareInitTask.h"
#include "user_SendTask.h"
#include "user_KeyTask.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Timers --------------------------------------------------------------------*/
osTimerId_t IdleTimerHandle;
/* Tasks ---------------------------------------------------------------------*/
// Hardwares initialization
osThreadId_t HardwareInitTaskHandle;
const osThreadAttr_t HardwareInitTask_attributes = {
.name = "HardwareInitTask",
.stack_size = 128 * 10,
.priority = (osPriority_t) osPriorityHigh3,
};
//UART send task
osThreadId_t UartSendTaskHandle;
const osThreadAttr_t UartSendTask_attributes = {
.name = "UartSendTask",
.stack_size = 128 * 2,
.priority = (osPriority_t) osPriorityHigh1,
};
//Key task
osThreadId_t KeyTaskHandle;
const osThreadAttr_t KeyTask_attributes = {
.name = "KeyTask",
.stack_size = 128 * 1,
.priority = (osPriority_t) osPriorityNormal,
};
//LVGL Handler task
osThreadId_t LvHandlerTaskHandle;
const osThreadAttr_t LvHandlerTask_attributes = {
.name = "LvHandlerTask",
.stack_size = 128 * 24,
.priority = (osPriority_t) osPriorityLow,
};
/* Message queues ------------------------------------------------------------*/
//Key message
osMessageQueueId_t Key_MessageQueue;
/* Private function prototypes -----------------------------------------------*/
void LvHandlerTask(void *argument);
/**
* @brief FreeRTOS initialization
* @param None
* @retval None
*/
void User_Tasks_Init(void)
{
/* add mutexes, ... */
/* add semaphores, ... */
/* start timers, add new ones, ... */
/* add queues, ... */
Key_MessageQueue = osMessageQueueNew(4, 1, NULL);
/* add threads, ... */
HardwareInitTaskHandle = osThreadNew(HardwareInitTask, NULL, &HardwareInitTask_attributes);
UartSendTaskHandle = osThreadNew(UartSendTask, NULL, &UartSendTask_attributes);
KeyTaskHandle = osThreadNew(KeyTask, NULL, &KeyTask_attributes);
LvHandlerTaskHandle = osThreadNew(LvHandlerTask, NULL, &LvHandlerTask_attributes);
/* add events, ... */
/* add others ... */
}
/**
* @brief FreeRTOS Tick Hook, to increase the LVGL tick
* @param None
* @retval None
*/
void TaskTickHook(void)
{
//to increase the LVGL tick
lv_tick_inc(1);
}
/**
* @brief LVGL Handler task, to run the lvgl
* @param argument: Not used
* @retval None
*/
void LvHandlerTask(void *argument)
{
while(1)
{
lv_task_handler();
osDelay(1);
}
}