mirror of
https://github.com/No-Chicken/Power-Pico.git
synced 2026-04-03 13:02:36 +08:00
add tasks
This commit is contained in:
16
Power_Pico/User/Tasks/Inc/user_KeyTask.h
Normal file
16
Power_Pico/User/Tasks/Inc/user_KeyTask.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef __USER_KEYTASK_H__
|
||||||
|
#define __USER_KEYTASK_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void KeyTask(void *argument);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
16
Power_Pico/User/Tasks/Inc/user_SendTask.h
Normal file
16
Power_Pico/User/Tasks/Inc/user_SendTask.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef __USER_SENDTASK_H__
|
||||||
|
#define __USER_SENDTASK_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void UartSendTask(void *argument);
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
51
Power_Pico/User/Tasks/Src/user_KeyTask.c
Normal file
51
Power_Pico/User/Tasks/Src/user_KeyTask.c
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/* Private includes -----------------------------------------------------------*/
|
||||||
|
//includes
|
||||||
|
#include "user_TasksInit.h"
|
||||||
|
#include "main.h"
|
||||||
|
#include "key.h"
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Key press check task
|
||||||
|
* @param argument: Not used
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void KeyTask(void *argument)
|
||||||
|
{
|
||||||
|
uint8_t keystr = 0;
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
keystr = KeyScan(0);
|
||||||
|
switch(keystr)
|
||||||
|
{
|
||||||
|
case KEYB_NUM:
|
||||||
|
osMessageQueuePut(Key_MessageQueue, &keystr, 0, 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEYY_NUM:
|
||||||
|
osMessageQueuePut(Key_MessageQueue, &keystr, 0, 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEYL_NUM:
|
||||||
|
osMessageQueuePut(Key_MessageQueue, &keystr, 0, 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEYR_NUM:
|
||||||
|
osMessageQueuePut(Key_MessageQueue, &keystr, 0, 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case KEYN_NUM:
|
||||||
|
osMessageQueuePut(Key_MessageQueue, &keystr, 0, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
osDelay(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
31
Power_Pico/User/Tasks/Src/user_SendTask.c
Normal file
31
Power_Pico/User/Tasks/Src/user_SendTask.c
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
/* Private includes -----------------------------------------------------------*/
|
||||||
|
//includes
|
||||||
|
#include "user_TasksInit.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief task for send messages or data
|
||||||
|
* @param argument: Not used
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void UartSendTask(void *argument)
|
||||||
|
{
|
||||||
|
uint8_t keystr = 0;
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
if(osMessageQueueGet(Key_MessageQueue, &keystr, NULL, 0)==osOK)
|
||||||
|
{
|
||||||
|
UART6_TX_Send((uint8_t *)"key pressed\r\n", 13);
|
||||||
|
}
|
||||||
|
osDelay(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,8 @@
|
|||||||
|
|
||||||
//tasks
|
//tasks
|
||||||
#include "user_HardwareInitTask.h"
|
#include "user_HardwareInitTask.h"
|
||||||
|
#include "user_SendTask.h"
|
||||||
|
#include "user_KeyTask.h"
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
|
||||||
@@ -34,12 +35,12 @@ const osThreadAttr_t HardwareInitTask_attributes = {
|
|||||||
.priority = (osPriority_t) osPriorityHigh3,
|
.priority = (osPriority_t) osPriorityHigh3,
|
||||||
};
|
};
|
||||||
|
|
||||||
//LVGL Handler task
|
//UART send task
|
||||||
osThreadId_t LvHandlerTaskHandle;
|
osThreadId_t UartSendTaskHandle;
|
||||||
const osThreadAttr_t LvHandlerTask_attributes = {
|
const osThreadAttr_t UartSendTask_attributes = {
|
||||||
.name = "LvHandlerTask",
|
.name = "UartSendTask",
|
||||||
.stack_size = 128 * 24,
|
.stack_size = 128 * 1,
|
||||||
.priority = (osPriority_t) osPriorityLow,
|
.priority = (osPriority_t) osPriorityHigh1,
|
||||||
};
|
};
|
||||||
|
|
||||||
//Key task
|
//Key task
|
||||||
@@ -50,6 +51,14 @@ const osThreadAttr_t KeyTask_attributes = {
|
|||||||
.priority = (osPriority_t) osPriorityNormal,
|
.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 ------------------------------------------------------------*/
|
/* Message queues ------------------------------------------------------------*/
|
||||||
//Key message
|
//Key message
|
||||||
@@ -72,13 +81,13 @@ void User_Tasks_Init(void)
|
|||||||
/* start timers, add new ones, ... */
|
/* start timers, add new ones, ... */
|
||||||
|
|
||||||
/* add queues, ... */
|
/* add queues, ... */
|
||||||
Key_MessageQueue = osMessageQueueNew(1, 1, NULL);
|
Key_MessageQueue = osMessageQueueNew(4, 1, NULL);
|
||||||
|
|
||||||
/* add threads, ... */
|
/* add threads, ... */
|
||||||
HardwareInitTaskHandle = osThreadNew(HardwareInitTask, NULL, &HardwareInitTask_attributes);
|
HardwareInitTaskHandle = osThreadNew(HardwareInitTask, NULL, &HardwareInitTask_attributes);
|
||||||
|
UartSendTaskHandle = osThreadNew(UartSendTask, NULL, &UartSendTask_attributes);
|
||||||
|
KeyTaskHandle = osThreadNew(KeyTask, NULL, &KeyTask_attributes);
|
||||||
LvHandlerTaskHandle = osThreadNew(LvHandlerTask, NULL, &LvHandlerTask_attributes);
|
LvHandlerTaskHandle = osThreadNew(LvHandlerTask, NULL, &LvHandlerTask_attributes);
|
||||||
// KeyTaskHandle = osThreadNew(KeyTask, NULL, &KeyTask_attributes);
|
|
||||||
|
|
||||||
|
|
||||||
/* add events, ... */
|
/* add events, ... */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user