@@ -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