CM_DOG/User/task/test.c
2025-06-24 10:28:20 +08:00

63 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
test Task
测试任务
*/
/* Includes ----------------------------------------------------------------- */
#include "task/user_task.h"
/* USER INCLUDE BEGIN*/
#include "bsp/uart.h"
#include "gom_protocol.h"
/* USER INCLUDE END*/
/* Private typedef ---------------------------------------------------------- */
/* Private define ----------------------------------------------------------- */
/* Private macro ------------------------------------------------------------ */
/* Private variables -------------------------------------------------------- */
/* USER STRUCT BEGIN*/
MotorCmd_t mcmd = {0};
MotorData_t data = {0};
/* USER STRUCT END*/
/* Private function --------------------------------------------------------- */
/* Exported functions ------------------------------------------------------- */
void Task_test(void *argument) {
(void)argument; /* 未使用argument消除警告 */
/* 计算任务运行到指定频率需要等待的tick数 */
const uint32_t delay_tick = osKernelGetTickFreq() / TEST_FREQ;
osDelay(TEST_INIT_DELAY); /* 延时一段时间再开启任务 */
/* USER CODE INIT BEGIN*/
mcmd.id = 0;
mcmd.mode = 1;
mcmd.K_P = 0;
mcmd.K_W = 0;
mcmd.Pos = 0;
mcmd.W = 0;
mcmd.T = 0;
/* USER CODE INIT END*/
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计时 */
while (1) {
tick += delay_tick; /* 计算下一个唤醒时刻 */
/* USER CODE BEGIN */
// modify_data(&mcmd);
// HAL_UART_Transmit(BSP_UART_GetHandle(BSP_UART_LEFT_LEG), (uint8_t *)&mcmd.motor_send_data, sizeof(mcmd.motor_send_data), 1);
// HAL_UART_Receive(BSP_UART_GetHandle(BSP_UART_LEFT_LEG), (uint8_t *)&data.motor_recv_data, sizeof(data.motor_recv_data), 1);
// extract_data(&data);
/* USER CODE END */
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
}
}