加入数据处理的任务

This commit is contained in:
不吃油炸鸡
2025-08-23 18:56:29 +08:00
parent cc7ade468b
commit bb209a9d45
3 changed files with 58 additions and 6 deletions

View File

@@ -0,0 +1,16 @@
#ifndef __USER_DATATASK_H__
#define __USER_DATATASK_H__
#ifdef __cplusplus
extern "C" {
#endif
void DataTask(void *argument);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,36 @@
/* Private includes -----------------------------------------------------------*/
//includes
#include "user_TasksInit.h"
#include "user_DataTask.h"
#include "main.h"
#include "adc.h"
#include "gate.h"
#include "usart.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/**
* @brief task for data process and so on
* @param argument: Not used
* @retval None
*/
void DataTask(void *argument)
{
uint8_t keystr = 0;
uint16_t cur_bias = 4096 / 2;
while(1)
{
if(osMessageQueueGet(Key_MessageQueue, &keystr, NULL, 0)==osOK)
{
// UART6_TX_Send((uint8_t *)"key pressed\r\n", 13);
}
osDelay(1);
}
}

View File

@@ -10,7 +10,7 @@
//tasks
#include "user_HardwareInitTask.h"
#include "user_SendTask.h"
#include "user_DataTask.h"
#include "user_KeyTask.h"
/* Private typedef -----------------------------------------------------------*/
@@ -35,10 +35,10 @@ const osThreadAttr_t HardwareInitTask_attributes = {
.priority = (osPriority_t) osPriorityHigh3,
};
//UART send task
osThreadId_t UartSendTaskHandle;
const osThreadAttr_t UartSendTask_attributes = {
.name = "UartSendTask",
//Data process task
osThreadId_t DataTaskHandle;
const osThreadAttr_t DataTask_attributes = {
.name = "DataTask",
.stack_size = 128 * 2,
.priority = (osPriority_t) osPriorityHigh1,
};
@@ -85,7 +85,7 @@ void User_Tasks_Init(void)
/* add threads, ... */
HardwareInitTaskHandle = osThreadNew(HardwareInitTask, NULL, &HardwareInitTask_attributes);
UartSendTaskHandle = osThreadNew(UartSendTask, NULL, &UartSendTask_attributes);
DataTaskHandle = osThreadNew(DataTask, NULL, &DataTask_attributes);
KeyTaskHandle = osThreadNew(KeyTask, NULL, &KeyTask_attributes);
LvHandlerTaskHandle = osThreadNew(LvHandlerTask, NULL, &LvHandlerTask_attributes);