fix: move DMA buffers from DTCM to RAM_D1, improve bsp_usart error recovery
- Add .dma_buf section in RAM_D1 for DMA-accessible USART instance pool. DTCM (0x20000000) is not reachable by DMA on STM32H7, causing bus errors (TE) when DMA writes to malloc'd buffers placed in DTCM by the XG linker script. - Replace malloc with static pool (usart_pool[]) placed in .dma_buf section. - In RxEventCallback, set recv_buff_size from Size so module callbacks know how many bytes were actually received. - Use USART_RXBUFF_LIMIT (256) as the DMA transfer size instead of per-module recv_buff_size. The actual buffer is always 256 bytes. - Remove recv_buff_size from USART_Init_Config_s; it is now set at runtime. - Flush RDR, clear error flags, and clear stale DMAR in error callback to prevent residual conditions from re-triggering errors on DMA restart. - Switch Vision module from UART10 to UART1.
This commit is contained in:
@@ -33,7 +33,6 @@ HC05 *HC05Init(UART_HandleTypeDef *hc05_usart_handle)
|
||||
USART_Init_Config_s conf;
|
||||
conf.module_callback = HC05RxCallback;
|
||||
conf.usart_handle = hc05_usart_handle;
|
||||
conf.recv_buff_size = HC05_BUFFERSIZE;
|
||||
hc05_usart_instance = USARTRegister(&conf);
|
||||
|
||||
hc05_init_flag = 1;
|
||||
|
||||
@@ -80,7 +80,6 @@ void Vision_Uart_Init(UART_HandleTypeDef *_handle)
|
||||
{
|
||||
USART_Init_Config_s conf = {
|
||||
.module_callback = DecodeVision,
|
||||
.recv_buff_size = 64,
|
||||
.usart_handle = _handle,
|
||||
};
|
||||
cv_usart_instance = USARTRegister(&conf);
|
||||
|
||||
@@ -125,7 +125,6 @@ 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; // mx 255(u8)
|
||||
referee_usart_instance = USARTRegister(&conf);
|
||||
|
||||
Daemon_Init_Config_s daemon_conf = {
|
||||
|
||||
@@ -229,7 +229,6 @@ RC_ctrl_t *RemoteControlInit(UART_HandleTypeDef *rc_usart_handle)
|
||||
USART_Init_Config_s conf;
|
||||
conf.module_callback = RemoteControlRxCallback;
|
||||
conf.usart_handle = rc_usart_handle;
|
||||
conf.recv_buff_size = REMOTE_CONTROL_FRAME_SIZE;
|
||||
rc_usart_instance = USARTRegister(&conf);
|
||||
|
||||
// 进行守护进程的注册,用于定时检查遥控器是否正常工作
|
||||
|
||||
@@ -59,7 +59,6 @@ board_comm_data_t* BoardCommInit(UART_HandleTypeDef *uart_handle)
|
||||
USART_Init_Config_s conf;
|
||||
conf.module_callback = BoardCommRxCallback;
|
||||
conf.usart_handle = uart_handle;
|
||||
conf.recv_buff_size = BOARD_COMM_FRAME_SIZE;
|
||||
board_comm_usart_instance = USARTRegister(&conf);
|
||||
|
||||
// 暂时注释掉 daemon 注册,专注于数据传输
|
||||
|
||||
Reference in New Issue
Block a user