shoot/User/task/can_task.c

37 lines
831 B
C
Raw Normal View History

2025-03-12 23:04:18 +08:00
/**
* can发送与解码任务
*/
#include "can_task.h"
#include "TopDefine.h"
#include "attrTask.h"
#include "djiMotor.h"
extern motor_measure_t *motor_3508_data;
/**
* \brief can任务
*
* \param argument 使
*/
void Task_Can(void *argument)
{
(void)argument; /* 未使用argument消除警告 */
2025-03-13 19:23:24 +08:00
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CAN;
2025-03-12 23:04:18 +08:00
djiInit();//FIFO滤波器初始化
Odrive_Can_Init();
uint32_t tick = osKernelGetTickCount(); /* 控制任务运行频率的计算 */
while(1)
{
waitNewDji();//等待新数据
djiMotorEncode();//数据解析
//将can数据添加到消息队列
2025-03-13 19:23:24 +08:00
tick += delay_tick; /* 计算下一个唤醒时刻 */
osDelayUntil(tick); /* 运行结束,等待下一个周期唤醒 */
2025-03-12 23:04:18 +08:00
}
}