mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
update
This commit is contained in:
15
Power_Pico/User/Tasks/Inc/user_HardwareInitTask.h
Normal file
15
Power_Pico/User/Tasks/Inc/user_HardwareInitTask.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef __USER_HARDWAREINITTASK_H__
|
||||
#define __USER_HARDWAREINITTASK_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void HardwareInitTask(void *argument);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
21
Power_Pico/User/Tasks/Inc/user_TasksInit.h
Normal file
21
Power_Pico/User/Tasks/Inc/user_TasksInit.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef __USER_TASKSINIT_H__
|
||||
#define __USER_TASKSINIT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
extern osMessageQueueId_t Key_MessageQueue;
|
||||
|
||||
void User_Tasks_Init(void);
|
||||
void TaskTickHook(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
69
Power_Pico/User/Tasks/Src/user_HardwareInitTask.c
Normal file
69
Power_Pico/User/Tasks/Src/user_HardwareInitTask.c
Normal file
@@ -0,0 +1,69 @@
|
||||
/* Private includes -----------------------------------------------------------*/
|
||||
|
||||
// includes
|
||||
// sys
|
||||
#include "usart.h"
|
||||
#include "tim.h"
|
||||
#include "stm32f4xx_it.h"
|
||||
|
||||
// user
|
||||
#include "user_TasksInit.h"
|
||||
|
||||
// bsp
|
||||
#include "key.h"
|
||||
#include "lcd.h"
|
||||
#include "lcd_init.h"
|
||||
|
||||
// ui
|
||||
#include "lvgl.h"
|
||||
#include "lv_port_disp.h"
|
||||
#include "ui.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief hardwares init task
|
||||
* @param argument: Not used
|
||||
* @retval None
|
||||
*/
|
||||
void HardwareInitTask(void *argument)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
vTaskSuspendAll();
|
||||
|
||||
// usart start
|
||||
|
||||
// PWM Start for LCD backlight
|
||||
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_3);
|
||||
|
||||
// key
|
||||
Key_Port_Init();
|
||||
|
||||
// lcd
|
||||
// done in lvgl disp init
|
||||
LCD_Init();
|
||||
LCD_Fill(0,0, LCD_W, LCD_H, BLACK);
|
||||
LCD_Set_Light(50);
|
||||
LCD_ShowString(72,LCD_H/2,(uint8_t*)"Welcome!", WHITE, BLACK, 24, 0);
|
||||
|
||||
// ui
|
||||
// LVGL and disp init
|
||||
lv_init();
|
||||
lv_port_disp_init();
|
||||
ui_init();
|
||||
|
||||
xTaskResumeAll();
|
||||
vTaskDelete(NULL);
|
||||
osDelay(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
119
Power_Pico/User/Tasks/Src/user_TasksInit.c
Normal file
119
Power_Pico/User/Tasks/Src/user_TasksInit.c
Normal file
@@ -0,0 +1,119 @@
|
||||
/* Private includes -----------------------------------------------------------*/
|
||||
//includes
|
||||
#include "user_TasksInit.h"
|
||||
//sys
|
||||
#include "sys.h"
|
||||
#include "stdio.h"
|
||||
|
||||
//gui
|
||||
#include "lvgl.h"
|
||||
|
||||
//tasks
|
||||
#include "user_HardwareInitTask.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,
|
||||
};
|
||||
|
||||
//LVGL Handler task
|
||||
osThreadId_t LvHandlerTaskHandle;
|
||||
const osThreadAttr_t LvHandlerTask_attributes = {
|
||||
.name = "LvHandlerTask",
|
||||
.stack_size = 128 * 24,
|
||||
.priority = (osPriority_t) osPriorityLow,
|
||||
};
|
||||
|
||||
//Key task
|
||||
osThreadId_t KeyTaskHandle;
|
||||
const osThreadAttr_t KeyTask_attributes = {
|
||||
.name = "KeyTask",
|
||||
.stack_size = 128 * 1,
|
||||
.priority = (osPriority_t) osPriorityNormal,
|
||||
};
|
||||
|
||||
|
||||
/* 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(1, 1, NULL);
|
||||
|
||||
/* add threads, ... */
|
||||
HardwareInitTaskHandle = osThreadNew(HardwareInitTask, NULL, &HardwareInitTask_attributes);
|
||||
LvHandlerTaskHandle = osThreadNew(LvHandlerTask, NULL, &LvHandlerTask_attributes);
|
||||
// KeyTaskHandle = osThreadNew(KeyTask, NULL, &KeyTask_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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user