diff options
| author | JOONH0o <[email protected]> | 2025-02-24 09:25:15 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-02-24 09:25:15 +0800 |
| commit | 3fdb94096794be237e52abff0fb4ee150efeee79 (patch) | |
| tree | 7c0f1951672c3aec653b5d5dbd9e451e6635aa96 | |
| parent | 5206b3ae2dbb455029696da0097c8ea3634b4af1 (diff) | |
fix - 1 优化中断中打印日志问题;2 优化SPI写外部FLASH慢的问题 (#10009)
* 1. 优化中断中打印日志问题;2 优化SPI写外部FLASH慢的问题
* 2. 在spi驱动中有在中断中打印调试信息的问题,增加ISR log判断进行
* 3. spi+DMA 写外部flash,由于spi速度很快,不进行delay就可以;同时,仿照Linux的驱动框架进行优化,数据小不使用DMA
| -rw-r--r-- | bsp/hc32/libraries/hc32_drivers/drv_eth.c | 4 | ||||
| -rw-r--r-- | bsp/hc32/libraries/hc32_drivers/drv_spi.c | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/bsp/hc32/libraries/hc32_drivers/drv_eth.c b/bsp/hc32/libraries/hc32_drivers/drv_eth.c index 573b70502a..043de32237 100644 --- a/bsp/hc32/libraries/hc32_drivers/drv_eth.c +++ b/bsp/hc32/libraries/hc32_drivers/drv_eth.c @@ -358,7 +358,9 @@ static void hc32_eth_irq_handle(stc_eth_handle_t *eth_handle) result = eth_device_ready(&(hc32_eth_device.parent)); if (result != RT_EOK) { +#if defined (RT_USING_ULOG) || defined (ULOG_USING_ISR_LOG) LOG_I("eth rx complete callback err = %d", result); +#endif } /* Clear the Eth DMA Rx IT pending bits */ ETH_DMA_ClearStatus(ETH_DMA_FLAG_RIS | ETH_DMA_FLAG_NIS); @@ -465,8 +467,10 @@ static void eth_phy_irq_handler(void *args) rt_uint16_t status = 0; ETH_PHY_ReadReg(&EthHandle, PHY_IISDR, &status); +#if defined (RT_USING_ULOG) || defined (ULOG_USING_ISR_LOG) LOG_D("phy interrupt status reg is 0x%X", status); #endif +#endif hc32_phy_link_change(); } #endif diff --git a/bsp/hc32/libraries/hc32_drivers/drv_spi.c b/bsp/hc32/libraries/hc32_drivers/drv_spi.c index eccc05e544..b67490f625 100644 --- a/bsp/hc32/libraries/hc32_drivers/drv_spi.c +++ b/bsp/hc32/libraries/hc32_drivers/drv_spi.c @@ -473,8 +473,6 @@ static int32_t hc32_spi_dma_trans(struct hc32_spi_config *spi_config, const uint while ((RESET == DMA_GetTransCompleteStatus(DmaInstance, DmaFlag)) && (u32TimeoutCnt < spi_config->timeout)) { - rt_thread_mdelay(1); - u32TimeoutCnt++; } if (u32TimeoutCnt >= spi_config->timeout) { @@ -544,7 +542,7 @@ static rt_ssize_t hc32_spi_xfer(struct rt_spi_device *device, struct rt_spi_mess if (message->send_buf && message->recv_buf) { hc32_spi_set_trans_mode(spi_instance, SPI_FULL_DUPLEX); - if ((spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_TX) && (spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_RX)) + if ((spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_TX) && (spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_RX) && (send_length > 32)) { state = hc32_spi_dma_trans(spi_drv->config, send_buf, recv_buf, send_length); } @@ -557,7 +555,7 @@ static rt_ssize_t hc32_spi_xfer(struct rt_spi_device *device, struct rt_spi_mess else if (message->send_buf) { hc32_spi_set_trans_mode(spi_instance, SPI_SEND_ONLY); - if (spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_TX) + if ((spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_TX) && (send_length > 32)) { state = hc32_spi_dma_trans(spi_drv->config, send_buf, RT_NULL, send_length); } @@ -601,8 +599,6 @@ static rt_ssize_t hc32_spi_xfer(struct rt_spi_device *device, struct rt_spi_mess while ((RESET == SPI_GetStatus(spi_instance, SPI_FLAG_IDLE)) && (u32TimeoutCnt < spi_drv->config->timeout)) { - rt_thread_mdelay(1); - u32TimeoutCnt++; } if (u32TimeoutCnt >= spi_drv->config->timeout) { |
