修复字节对齐问题

This commit is contained in:
kidneygood 2022-11-18 22:53:53 +08:00
parent 611db0ded1
commit 0d94ff3f28
5 changed files with 6 additions and 2 deletions

View File

@ -48,6 +48,7 @@
"stdio.h": "c", "stdio.h": "c",
"segger_rtt_conf.h": "c", "segger_rtt_conf.h": "c",
"segger_rtt.h": "c", "segger_rtt.h": "c",
"bsp_log.h": "c" "bsp_log.h": "c",
"referee.h": "c"
} }
} }

View File

@ -66,6 +66,7 @@ void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
if (huart == instance[i]->usart_handle) if (huart == instance[i]->usart_handle)
{ {
instance[i]->module_callback(); 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_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); __HAL_DMA_DISABLE_IT(instance[i]->usart_handle->hdmarx, DMA_IT_HT);
break; break;

View File

@ -5,7 +5,7 @@
#include "main.h" #include "main.h"
#define DEVICE_USART_CNT 3 // C板至多分配3个串口 #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,解析协议的回调函数 */ /* application callback,which resolves specific protocol,解析协议的回调函数 */
typedef void (*usart_module_callback)(); typedef void (*usart_module_callback)();

View File

@ -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); Judge_Read_Data(ReadFromUsart + sizeof(xFrameHeader) + LEN_CMDID + referee_info.FrameHeader.DataLength + LEN_TAIL);
} }
} }

View File

@ -31,6 +31,7 @@
//起始字节,协议固定为0xA5 //起始字节,协议固定为0xA5
#define JUDGE_FRAME_HEADER (0xA5) #define JUDGE_FRAME_HEADER (0xA5)
#pragma pack(1)
/***************裁判系统数据接收********************/ /***************裁判系统数据接收********************/