@@ -104,20 +104,26 @@ static inline bool SPI_SLAVE_ISR_ATTR bus_is_iomux(spi_slave_t *host)
104104 return host -> flags & SPICOMMON_BUSFLAG_IOMUX_PINS ;
105105}
106106
107- static void SPI_SLAVE_ISR_ATTR freeze_cs (spi_slave_t * host )
107+ static inline void SPI_SLAVE_ISR_ATTR freeze_cs (spi_slave_t * host )
108108{
109+ #if SPI_LL_SLAVE_NEEDS_CS_WORKAROUND
110+ // This workaround only for ESP32 due to old hardware design, see MR !3207
109111 esp_rom_gpio_connect_in_signal (GPIO_MATRIX_CONST_ONE_INPUT , host -> cs_in_signal , false);
112+ #endif
110113}
111114
112115// Use this function instead of cs_initial to avoid overwrite the output config
113116// This is used in test by internal gpio matrix connections
114117static inline void SPI_SLAVE_ISR_ATTR restore_cs (spi_slave_t * host )
115118{
119+ #if SPI_LL_SLAVE_NEEDS_CS_WORKAROUND
120+ // This workaround only for ESP32 due to old hardware design, see MR !3207
116121 if (host -> cs_iomux ) {
117122 gpio_ll_set_input_signal_from (GPIO_HAL_GET_HW (GPIO_PORT_0 ), host -> cs_in_signal , false);
118123 } else {
119124 esp_rom_gpio_connect_in_signal (host -> cfg .spics_io_num , host -> cs_in_signal , false);
120125 }
126+ #endif
121127}
122128
123129#if (SOC_CPU_CORES_NUM > 1 ) && (!CONFIG_FREERTOS_UNICORE )
@@ -640,21 +646,13 @@ static void SPI_SLAVE_ISR_ATTR s_spi_slave_dma_prepare_data(spi_dma_ctx_t *dma_c
640646
641647 spi_dma_reset (dma_ctx -> rx_dma_chan );
642648 spi_slave_hal_hw_prepare_rx (hal -> hw );
649+ spi_dma_start (dma_ctx -> rx_dma_chan , dma_ctx -> dmadesc_rx );
643650 }
644651 if (hal -> tx_buffer ) {
645652 spicommon_dma_desc_setup_link (dma_ctx -> dmadesc_tx , hal -> tx_buffer , (hal -> bitlen + 7 ) / 8 , false);
646653
647654 spi_dma_reset (dma_ctx -> tx_dma_chan );
648655 spi_slave_hal_hw_prepare_tx (hal -> hw );
649- }
650- }
651-
652- static void SPI_SLAVE_ISR_ATTR s_spi_slave_start_dma (spi_dma_ctx_t * dma_ctx , spi_slave_hal_context_t * hal )
653- {
654- if (hal -> rx_buffer ) {
655- spi_dma_start (dma_ctx -> rx_dma_chan , dma_ctx -> dmadesc_rx );
656- }
657- if (hal -> tx_buffer ) {
658656 spi_dma_start (dma_ctx -> tx_dma_chan , dma_ctx -> dmadesc_tx );
659657 }
660658}
@@ -784,10 +782,7 @@ static void SPI_SLAVE_ISR_ATTR spi_intr(void *arg)
784782
785783 //The slave rx dma get disturbed by unexpected transaction. Only connect the CS and start DMA when slave is ready.
786784 if (use_dma ) {
787- // Note: order of restore_cs and s_spi_slave_start_dma is important
788- // restore_cs also bring potential glitch, should happen before start DMA
789785 restore_cs (host );
790- s_spi_slave_start_dma (host -> dma_ctx , hal );
791786 }
792787
793788 //Kick off transfer
0 commit comments