From b37ceaa2e90e3739074c48e44151facbf3f37de6 Mon Sep 17 00:00:00 2001 From: Kidenygood <2979564623@qq.com> Date: Mon, 3 Apr 2023 21:01:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E7=BC=93=E5=86=B2=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HAL_N_Middlewares/Src/main.c | 3 +-- application/referee/referee.c | 2 ++ application/robot.c | 3 ++- modules/referee/referee_UI.c | 10 +++++----- modules/referee/referee_communication.c | 2 +- modules/referee/rm_referee.c | 7 ++++--- modules/referee/rm_referee.h | 4 ++-- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/HAL_N_Middlewares/Src/main.c b/HAL_N_Middlewares/Src/main.c index df310d0..a06f22e 100644 --- a/HAL_N_Middlewares/Src/main.c +++ b/HAL_N_Middlewares/Src/main.c @@ -83,8 +83,7 @@ int main(void) /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ - HAL_Init(); - + HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ diff --git a/application/referee/referee.c b/application/referee/referee.c index 04a86fe..facaa56 100644 --- a/application/referee/referee.c +++ b/application/referee/referee.c @@ -381,4 +381,6 @@ static void UI_test_init(referee_info_t *_referee_info) Char_Draw(&sdata[0], "s7", UI_Graph_ADD, 0, UI_Color_Green, 20, 2, 620, 710); Char_Write(&sdata[0], "number:%d", 123); Char_ReFresh(&_referee_info->referee_id, sdata[0]); + + RefereeSend(); } diff --git a/application/robot.c b/application/robot.c index 6463b39..7806bea 100644 --- a/application/robot.c +++ b/application/robot.c @@ -35,11 +35,12 @@ void RobotInit() #endif #if defined(ONE_BOARD) || defined(CHASSIS_BOARD) - // Referee_Interactive_init(); + ChassisInit(); #endif // 初始化完成,开启中断 __enable_irq(); + Referee_Interactive_init(); } void RobotTask() diff --git a/modules/referee/referee_UI.c b/modules/referee/referee_UI.c index 2dc3e36..e40a95a 100644 --- a/modules/referee/referee_UI.c +++ b/modules/referee/referee_UI.c @@ -42,7 +42,7 @@ void UI_Delete(referee_id_t *_id, uint8_t Del_Operate, uint8_t Del_Layer) UI_delete_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_delete_data, LEN_HEADER + LEN_CMDID + temp_datalength, 0xFFFF); /* 填入0xFFFF,关于crc校验 */ - RefereeSend((uint8_t *)&UI_delete_data, LEN_HEADER + LEN_CMDID + temp_datalength + LEN_TAIL); // 发送 + RefereeLoadToBuffer((uint8_t *)&UI_delete_data, LEN_HEADER + LEN_CMDID + temp_datalength + LEN_TAIL); // 发送 UI_Seq++; // 包序号+1 } @@ -388,17 +388,17 @@ void UI_ReFresh(referee_id_t *_id, int cnt, ...) // 先发送帧头、命令码、交互数据帧头三部分,并计算CRC16校验值 UI_GraphReFresh_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_GraphReFresh_data, LEN_HEADER + LEN_CMDID + Interactive_Data_LEN_Head, 0xFFFF); - RefereeSend((uint8_t *)&UI_GraphReFresh_data, LEN_HEADER + LEN_CMDID + Interactive_Data_LEN_Head); + RefereeLoadToBuffer((uint8_t *)&UI_GraphReFresh_data, LEN_HEADER + LEN_CMDID + Interactive_Data_LEN_Head); for (i = 0; i < cnt; i++) // 发送交互数据的数据帧,并计算CRC16校验值 { graphData = va_arg(ap, Graph_Data_t); // 访问参数列表中的每个项,第二个参数是你要返回的参数的类型,在取值时需要将其强制转化为指定类型的变量 // 发送并计算CRC16 - RefereeSend((uint8_t *)&graphData, UI_Operate_LEN_PerDraw); + RefereeLoadToBuffer((uint8_t *)&graphData, UI_Operate_LEN_PerDraw); UI_GraphReFresh_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&graphData, UI_Operate_LEN_PerDraw, UI_GraphReFresh_data.frametail); } - RefereeSend((uint8_t *)&UI_GraphReFresh_data.frametail, LEN_TAIL); // 发送CRC16校验值 + RefereeLoadToBuffer((uint8_t *)&UI_GraphReFresh_data.frametail, LEN_TAIL); // 发送CRC16校验值 va_end(ap); // 结束可变参数的获取 UI_Seq++; // 包序号+1 @@ -427,7 +427,7 @@ void Char_ReFresh(referee_id_t *_id, String_Data_t string_Data) UI_CharReFresh_data.frametail = Get_CRC16_Check_Sum((uint8_t *)&UI_CharReFresh_data, LEN_HEADER + LEN_CMDID + temp_datalength, 0xFFFF); - RefereeSend((uint8_t *)&UI_CharReFresh_data, LEN_HEADER + LEN_CMDID + temp_datalength + LEN_TAIL); // 发送 + RefereeLoadToBuffer((uint8_t *)&UI_CharReFresh_data, LEN_HEADER + LEN_CMDID + temp_datalength + LEN_TAIL); // 发送 UI_Seq++; // 包序号+1 } diff --git a/modules/referee/referee_communication.c b/modules/referee/referee_communication.c index d714605..fb93438 100644 --- a/modules/referee/referee_communication.c +++ b/modules/referee/referee_communication.c @@ -40,6 +40,6 @@ void Communicate_SendData(referee_id_t *_id,robot_interactive_data_t *_data) SendData.frametail = Get_CRC16_Check_Sum((uint8_t *)&SendData,LEN_HEADER+LEN_CMDID+temp_datalength,0xFFFF); - RefereeSend((uint8_t *)&SendData,LEN_HEADER+LEN_CMDID+temp_datalength+LEN_TAIL); //发送 + RefereeLoadToBuffer((uint8_t *)&SendData,LEN_HEADER+LEN_CMDID+temp_datalength+LEN_TAIL); //发送 UI_Seq++; // 包序号+1 } diff --git a/modules/referee/rm_referee.c b/modules/referee/rm_referee.c index 7e9471b..a91206e 100644 --- a/modules/referee/rm_referee.c +++ b/modules/referee/rm_referee.c @@ -48,11 +48,12 @@ void RefereeLoadToBuffer(uint8_t *send, uint16_t tx_len) /** * @brief 发送函数 - * @param send 待发送数据 + * @param */ -void RefereeSend(uint8_t *send, uint16_t tx_len) +void RefereeSend() { - USARTSend(referee_usart_instance, send, tx_len,USART_TRANSFER_IT);//syhtodo此函数需要重写 + USARTSend(referee_usart_instance, (uint8_t *)(&referee_tx_buffer.buffer), referee_tx_buffer.pos,USART_TRANSFER_DMA); + referee_tx_buffer.pos=0; /* syhtodo DMA请求过快会导致数据发送丢失,考虑数据尽可能打成一个整包以及队列发送,并且发送函数添加缓冲区 */ } diff --git a/modules/referee/rm_referee.h b/modules/referee/rm_referee.h index 08d9a01..8c1e50c 100644 --- a/modules/referee/rm_referee.h +++ b/modules/referee/rm_referee.h @@ -68,8 +68,8 @@ void RefereeLoadToBuffer(uint8_t *send, uint16_t tx_len); /** * @brief 发送函数 * @todo - * @param send 待发送数据 + * @param */ -void RefereeSend(uint8_t *send, uint16_t tx_len); +void RefereeSend(void); #endif // !REFEREE_H