diff --git a/modules/referee/referee.c b/modules/referee/referee.c index f863717..f6640fa 100644 --- a/modules/referee/referee.c +++ b/modules/referee/referee.c @@ -15,28 +15,13 @@ static referee_info_t referee_info; static uint8_t Judge_Self_ID; // 当前机器人的ID static uint16_t Judge_SelfClient_ID; // 发送者机器人对应的客户端ID -static void RefereeRxCallback() -{ - JudgeReadData(referee_usart_instance->recv_buff); -} - -referee_info_t *RefereeInit(UART_HandleTypeDef *referee_usart_handle) -{ - USART_Init_Config_s conf; - conf.module_callback = RefereeRxCallback; - conf.usart_handle = referee_usart_handle; - conf.recv_buff_size = RE_RX_BUFFER_SIZE; - referee_usart_instance = USARTRegister(&conf); - return &referee_info; -} - /** * @brief 读取裁判数据,中断中读取保证速度 * @param 缓存数据 * @retval 是否对正误判断做处理 * @attention 在此判断帧头和CRC校验,无误再写入数据,不重复判断帧头 */ -void JudgeReadData(uint8_t *ReadFromUsart) +static void JudgeReadData(uint8_t *ReadFromUsart) { uint16_t judge_length; // 统计一帧数据长度 // referee_info.CmdID = 0; //数据命令码解析 @@ -121,4 +106,23 @@ void JudgeReadData(uint8_t *ReadFromUsart) JudgeReadData(ReadFromUsart + sizeof(xFrameHeader) + LEN_CMDID + referee_info.FrameHeader.DataLength + LEN_TAIL); } } +} + +/** + * @brief 裁判系统串口接收回调函数,解析数据 + * + */ +static void RefereeRxCallback() +{ + JudgeReadData(referee_usart_instance->recv_buff); +} + +referee_info_t *RefereeInit(UART_HandleTypeDef *referee_usart_handle) +{ + USART_Init_Config_s conf; + conf.module_callback = RefereeRxCallback; + conf.usart_handle = referee_usart_handle; + conf.recv_buff_size = RE_RX_BUFFER_SIZE; + referee_usart_instance = USARTRegister(&conf); + return &referee_info; } \ No newline at end of file diff --git a/modules/referee/referee.h b/modules/referee/referee.h index 64f9b56..b2238c9 100644 --- a/modules/referee/referee.h +++ b/modules/referee/referee.h @@ -344,7 +344,7 @@ typedef struct #pragma pack() /** - * @brief + * @brief 初始化裁判系统,返回接收数据指针 * * @param referee_usart_handle * @return referee_info_t*