52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
/*
|
|
*文件名称:referee_task.c
|
|
*功能描述:裁判系统链路监测任务(100ms)
|
|
*备注:数据解析在USART6空闲中断内由referee_parse_bytes完成,本任务仅做超时监测与心跳上报
|
|
*/
|
|
#include "app_tasks.h"
|
|
#include "cmsis_os.h"
|
|
#include "bsp_usart.h"
|
|
#include "referee.h"
|
|
#include "robot_param.h"
|
|
|
|
/*
|
|
*函数简介:USART6裁判系统整帧接收回调
|
|
*参数说明:frame:接收帧数据指针
|
|
*参数说明:len:接收帧字节长度
|
|
*返回类型:无
|
|
*备注:将接收字节流喂入裁判系统解析状态机
|
|
*/
|
|
void referee_frame_callback(const uint8_t * frame, uint16_t len)
|
|
{
|
|
if (frame == NULL || len == 0U)
|
|
return;
|
|
|
|
referee_parse_bytes(frame, len);
|
|
}
|
|
|
|
/*
|
|
*函数简介:裁判系统链路超时监测任务(100ms)
|
|
*参数说明:argument:FreeRTOS任务参数(未使用)
|
|
*返回类型:无
|
|
*备注:无
|
|
*/
|
|
void referee_task(void const * argument)
|
|
{
|
|
(void)argument;
|
|
|
|
while (!app_ready)
|
|
osDelay(2);
|
|
|
|
for (;;)
|
|
{
|
|
if (referee.link_status &&
|
|
(HAL_GetTick() - referee.last_update_tick > DEVICE_OFFLINE_TIME_MS * 10U))
|
|
{
|
|
referee.link_status = 0U;//链路超时置断线
|
|
}
|
|
|
|
monitor_heartbeat(HB_REFEREE);
|
|
osDelay(100);
|
|
}
|
|
}
|