增加调试打印输出
This commit is contained in:
@@ -17,6 +17,12 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* 调试输出配置
|
||||
*/
|
||||
#define DBG_TAG "[CH395]"
|
||||
#include "dbg_log.h"
|
||||
|
||||
/*
|
||||
* 私有宏定义区
|
||||
*/
|
||||
@@ -85,11 +91,11 @@ static void ch395f_spi_dma_transfer(uint16_t len)
|
||||
status = HAL_SPI_TransmitReceive_DMA(&hspi2, s_spi2_dma_tx_buf, s_spi2_dma_rx_buf, len);
|
||||
if (status != HAL_OK)
|
||||
{
|
||||
printf("[DMA] HAL_SPI_TransmitReceive_DMA FAIL: %d, SPI_State=%d, SPI_Error=0x%lX, DMA_State=%d\r\n",
|
||||
(int)status,
|
||||
(int)hspi2.State,
|
||||
hspi2.ErrorCode,
|
||||
(int)hspi2.hdmarx->State);
|
||||
DBG_ERROR("HAL_SPI_TransmitReceive_DMA FAIL: %d, SPI_State=%d, SPI_Error=0x%lX, DMA_State=%d",
|
||||
(int)status,
|
||||
(int)hspi2.State,
|
||||
hspi2.ErrorCode,
|
||||
(int)hspi2.hdmarx->State);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -99,20 +105,20 @@ static void ch395f_spi_dma_transfer(uint16_t len)
|
||||
loop_cnt++;
|
||||
if ((HAL_GetTick() - tickstart) > 1000U)
|
||||
{
|
||||
printf("[DMA] TIMEOUT after 1s, len=%d, loop=%lu, SPI_State=%d, SPI_Error=0x%lX\r\n",
|
||||
(int)len, loop_cnt,
|
||||
(int)hspi2.State,
|
||||
hspi2.ErrorCode);
|
||||
printf("[DMA] DMA_RX: State=%d, Dir=%lu, CNT=%lu\r\n",
|
||||
(int)hspi2.hdmarx->State,
|
||||
hspi2.hdmarx->Init.Direction,
|
||||
__HAL_DMA_GET_COUNTER(hspi2.hdmarx));
|
||||
printf("[DMA] DMA_TX: State=%d, Dir=%lu, CNT=%lu\r\n",
|
||||
(int)hspi2.hdmatx->State,
|
||||
hspi2.hdmatx->Init.Direction,
|
||||
__HAL_DMA_GET_COUNTER(hspi2.hdmatx));
|
||||
printf("[DMA] SPI2_CR1=0x%lX, CR2=0x%lX, SR=0x%lX\r\n",
|
||||
SPI2->CR1, SPI2->CR2, SPI2->SR);
|
||||
DBG_ERROR("TIMEOUT after 1s, len=%d, loop=%lu, SPI_State=%d, SPI_Error=0x%lX",
|
||||
(int)len, loop_cnt,
|
||||
(int)hspi2.State,
|
||||
hspi2.ErrorCode);
|
||||
DBG_ERROR(" DMA_RX: State=%d, Dir=%lu, CNT=%lu",
|
||||
(int)hspi2.hdmarx->State,
|
||||
hspi2.hdmarx->Init.Direction,
|
||||
__HAL_DMA_GET_COUNTER(hspi2.hdmarx));
|
||||
DBG_ERROR(" DMA_TX: State=%d, Dir=%lu, CNT=%lu",
|
||||
(int)hspi2.hdmatx->State,
|
||||
hspi2.hdmatx->Init.Direction,
|
||||
__HAL_DMA_GET_COUNTER(hspi2.hdmatx));
|
||||
DBG_ERROR(" SPI2_CR1=0x%lX, CR2=0x%lX, SR=0x%lX",
|
||||
SPI2->CR1, SPI2->CR2, SPI2->SR);
|
||||
/* 强制复位 SPI2 DMA 状态,避免死锁 */
|
||||
HAL_SPI_Abort(&hspi2);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user