From 0d94ff3f284fb7d43cb848520acded7b9796facb Mon Sep 17 00:00:00 2001 From: kidneygood <2979564623@qq.com> Date: Fri, 18 Nov 2022 22:53:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=97=E8=8A=82=E5=AF=B9?= =?UTF-8?q?=E9=BD=90=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 ++- bsp/bsp_usart.c | 1 + bsp/bsp_usart.h | 2 +- modules/referee/referee.c | 1 + modules/referee/referee.h | 1 + 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index b95b67e..967911d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -48,6 +48,7 @@ "stdio.h": "c", "segger_rtt_conf.h": "c", "segger_rtt.h": "c", - "bsp_log.h": "c" + "bsp_log.h": "c", + "referee.h": "c" } } \ No newline at end of file diff --git a/bsp/bsp_usart.c b/bsp/bsp_usart.c index e33b0e7..c473608 100644 --- a/bsp/bsp_usart.c +++ b/bsp/bsp_usart.c @@ -66,6 +66,7 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) if (huart == instance[i]->usart_handle) { instance[i]->module_callback(); + memset(instance[i]->recv_buff,0,instance[i]->recv_buff_size); HAL_UARTEx_ReceiveToIdle_DMA(instance[i]->usart_handle, instance[i]->recv_buff, instance[i]->recv_buff_size); __HAL_DMA_DISABLE_IT(instance[i]->usart_handle->hdmarx, DMA_IT_HT); break; diff --git a/bsp/bsp_usart.h b/bsp/bsp_usart.h index 035500a..c70b925 100644 --- a/bsp/bsp_usart.h +++ b/bsp/bsp_usart.h @@ -5,7 +5,7 @@ #include "main.h" #define DEVICE_USART_CNT 3 // C板至多分配3个串口 -#define USART_RXBUFF_LIMIT 512 // if your protocol needs bigger buff, modify here +#define USART_RXBUFF_LIMIT 256 // if your protocol needs bigger buff, modify here /* application callback,which resolves specific protocol,解析协议的回调函数 */ typedef void (*usart_module_callback)(); diff --git a/modules/referee/referee.c b/modules/referee/referee.c index a7a5f36..df38ea4 100644 --- a/modules/referee/referee.c +++ b/modules/referee/referee.c @@ -126,6 +126,7 @@ bool_t Judge_Read_Data(uint8_t *ReadFromUsart) { //如果一个数据包出现了多帧数据,则再次读取 Judge_Read_Data(ReadFromUsart + sizeof(xFrameHeader) + LEN_CMDID + referee_info.FrameHeader.DataLength + LEN_TAIL); + } } diff --git a/modules/referee/referee.h b/modules/referee/referee.h index 1744729..d8e967c 100644 --- a/modules/referee/referee.h +++ b/modules/referee/referee.h @@ -31,6 +31,7 @@ //起始字节,协议固定为0xA5 #define JUDGE_FRAME_HEADER (0xA5) +#pragma pack(1) /***************裁判系统数据接收********************/