forked from espressif/esp-idf
spi_slave: fix slave can't use iomux bus mixed with gpio cs_pin
This commit is contained in:
@@ -64,6 +64,7 @@ typedef struct {
|
|||||||
QueueHandle_t trans_queue;
|
QueueHandle_t trans_queue;
|
||||||
QueueHandle_t ret_queue;
|
QueueHandle_t ret_queue;
|
||||||
int dma_chan;
|
int dma_chan;
|
||||||
|
bool cs_iomux;
|
||||||
#ifdef CONFIG_PM_ENABLE
|
#ifdef CONFIG_PM_ENABLE
|
||||||
esp_pm_lock_handle_t pm_lock;
|
esp_pm_lock_handle_t pm_lock;
|
||||||
#endif
|
#endif
|
||||||
@@ -97,7 +98,7 @@ static void SPI_SLAVE_ISR_ATTR freeze_cs(spi_slave_t *host)
|
|||||||
// This is used in test by internal gpio matrix connections
|
// This is used in test by internal gpio matrix connections
|
||||||
static inline void SPI_SLAVE_ISR_ATTR restore_cs(spi_slave_t *host)
|
static inline void SPI_SLAVE_ISR_ATTR restore_cs(spi_slave_t *host)
|
||||||
{
|
{
|
||||||
if (bus_is_iomux(host)) {
|
if (host->cs_iomux) {
|
||||||
gpio_iomux_in(host->cfg.spics_io_num, spi_periph_signal[host->id].spics_in);
|
gpio_iomux_in(host->cfg.spics_io_num, spi_periph_signal[host->id].spics_in);
|
||||||
} else {
|
} else {
|
||||||
gpio_matrix_in(host->cfg.spics_io_num, spi_periph_signal[host->id].spics_in, false);
|
gpio_matrix_in(host->cfg.spics_io_num, spi_periph_signal[host->id].spics_in, false);
|
||||||
@@ -147,7 +148,12 @@ esp_err_t spi_slave_initialize(spi_host_device_t host, const spi_bus_config_t *b
|
|||||||
ret = err;
|
ret = err;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
if (slave_config->spics_io_num >= 0) {
|
||||||
spicommon_cs_initialize(host, slave_config->spics_io_num, 0, !bus_is_iomux(spihost[host]));
|
spicommon_cs_initialize(host, slave_config->spics_io_num, 0, !bus_is_iomux(spihost[host]));
|
||||||
|
// check and save where cs line really route through
|
||||||
|
spihost[host]->cs_iomux = (slave_config->spics_io_num == spi_periph_signal[host].spics0_iomux_pin) && bus_is_iomux(spihost[host]);
|
||||||
|
}
|
||||||
|
|
||||||
// The slave DMA suffers from unexpected transactions. Forbid reading if DMA is enabled by disabling the CS line.
|
// The slave DMA suffers from unexpected transactions. Forbid reading if DMA is enabled by disabling the CS line.
|
||||||
if (use_dma) freeze_cs(spihost[host]);
|
if (use_dma) freeze_cs(spihost[host]);
|
||||||
|
|
||||||
@@ -404,4 +410,3 @@ static void SPI_SLAVE_ISR_ATTR spi_intr(void *arg)
|
|||||||
}
|
}
|
||||||
if (do_yield) portYIELD_FROM_ISR();
|
if (do_yield) portYIELD_FROM_ISR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user