Skip to content

Commit 3fdb940

Browse files
authored
fix - 1 优化中断中打印日志问题;2 优化SPI写外部FLASH慢的问题 (#10009)
* 1. 优化中断中打印日志问题;2 优化SPI写外部FLASH慢的问题 * 2. 在spi驱动中有在中断中打印调试信息的问题,增加ISR log判断进行 * 3. spi+DMA 写外部flash,由于spi速度很快,不进行delay就可以;同时,仿照Linux的驱动框架进行优化,数据小不使用DMA
1 parent 5206b3a commit 3fdb940

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

bsp/hc32/libraries/hc32_drivers/drv_eth.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,9 @@ static void hc32_eth_irq_handle(stc_eth_handle_t *eth_handle)
358358
result = eth_device_ready(&(hc32_eth_device.parent));
359359
if (result != RT_EOK)
360360
{
361+
#if defined (RT_USING_ULOG) || defined (ULOG_USING_ISR_LOG)
361362
LOG_I("eth rx complete callback err = %d", result);
363+
#endif
362364
}
363365
/* Clear the Eth DMA Rx IT pending bits */
364366
ETH_DMA_ClearStatus(ETH_DMA_FLAG_RIS | ETH_DMA_FLAG_NIS);
@@ -465,7 +467,9 @@ static void eth_phy_irq_handler(void *args)
465467
rt_uint16_t status = 0;
466468

467469
ETH_PHY_ReadReg(&EthHandle, PHY_IISDR, &status);
470+
#if defined (RT_USING_ULOG) || defined (ULOG_USING_ISR_LOG)
468471
LOG_D("phy interrupt status reg is 0x%X", status);
472+
#endif
469473
#endif
470474
hc32_phy_link_change();
471475
}

bsp/hc32/libraries/hc32_drivers/drv_spi.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,6 @@ static int32_t hc32_spi_dma_trans(struct hc32_spi_config *spi_config, const uint
473473
while ((RESET == DMA_GetTransCompleteStatus(DmaInstance, DmaFlag)) &&
474474
(u32TimeoutCnt < spi_config->timeout))
475475
{
476-
rt_thread_mdelay(1);
477-
u32TimeoutCnt++;
478476
}
479477
if (u32TimeoutCnt >= spi_config->timeout)
480478
{
@@ -544,7 +542,7 @@ static rt_ssize_t hc32_spi_xfer(struct rt_spi_device *device, struct rt_spi_mess
544542
if (message->send_buf && message->recv_buf)
545543
{
546544
hc32_spi_set_trans_mode(spi_instance, SPI_FULL_DUPLEX);
547-
if ((spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_TX) && (spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_RX))
545+
if ((spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_TX) && (spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_RX) && (send_length > 32))
548546
{
549547
state = hc32_spi_dma_trans(spi_drv->config, send_buf, recv_buf, send_length);
550548
}
@@ -557,7 +555,7 @@ static rt_ssize_t hc32_spi_xfer(struct rt_spi_device *device, struct rt_spi_mess
557555
else if (message->send_buf)
558556
{
559557
hc32_spi_set_trans_mode(spi_instance, SPI_SEND_ONLY);
560-
if (spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_TX)
558+
if ((spi_drv->spi_dma_flag & RT_DEVICE_FLAG_DMA_TX) && (send_length > 32))
561559
{
562560
state = hc32_spi_dma_trans(spi_drv->config, send_buf, RT_NULL, send_length);
563561
}
@@ -601,8 +599,6 @@ static rt_ssize_t hc32_spi_xfer(struct rt_spi_device *device, struct rt_spi_mess
601599
while ((RESET == SPI_GetStatus(spi_instance, SPI_FLAG_IDLE)) &&
602600
(u32TimeoutCnt < spi_drv->config->timeout))
603601
{
604-
rt_thread_mdelay(1);
605-
u32TimeoutCnt++;
606602
}
607603
if (u32TimeoutCnt >= spi_drv->config->timeout)
608604
{

0 commit comments

Comments
 (0)