通过测试排除了一些问题
This commit is contained in:
@@ -124,6 +124,14 @@ static void ch395f_spi_dma_transfer(uint16_t len)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* 检查传输是否成功:SPI 错误码必须为 0 */
|
||||
if (hspi2.ErrorCode != 0U)
|
||||
{
|
||||
DBG_INFO("SPI DMA done with errors: ErrorCode=0x%lX, SPI_State=%d",
|
||||
hspi2.ErrorCode, (int)hspi2.State);
|
||||
__HAL_SPI_CLEAR_OVRFLAG(&hspi2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1177,6 +1185,9 @@ void ch395f_write_send_buf(uint8_t sock, uint8_t *p_data, uint16_t len)
|
||||
/* 拷贝用户数据到 DMA 发送缓冲区 */
|
||||
memcpy(&s_spi2_dma_tx_buf[4], p_data, len);
|
||||
|
||||
/* 数据同步屏障:确保 memcpy 写入在 DMA 读取前对总线可见 */
|
||||
__DSB();
|
||||
|
||||
/* CS 拉低 -> DMA 批量传输 -> CS 拉高 */
|
||||
ch395f_spi_begin();
|
||||
ch395f_spi_dma_transfer(total);
|
||||
|
||||
Reference in New Issue
Block a user