diff --git a/components/driver/include/driver/spi_common.h b/components/driver/include/driver/spi_common.h index e038c6325..b44159546 100644 --- a/components/driver/include/driver/spi_common.h +++ b/components/driver/include/driver/spi_common.h @@ -310,6 +310,17 @@ void spicommon_cs_free_io(int cs_gpio_num); */ bool spicommon_bus_using_iomux(spi_host_device_t host); +/** + * @brief Check whether all pins used by a host are through IOMUX. + * + * @param host SPI peripheral + * + * @note This public API is deprecated. + * + * @return false if any pins are through the GPIO matrix, otherwise true. + */ +bool spicommon_bus_using_iomux(spi_host_device_t host); + /** * @brief Get the IRQ source for a specific SPI host * diff --git a/components/driver/spi_common.c b/components/driver/spi_common.c index 32d3442c1..ff7501eaf 100644 --- a/components/driver/spi_common.c +++ b/components/driver/spi_common.c @@ -352,6 +352,17 @@ void spicommon_cs_free_io(int cs_gpio_num) gpio_reset_pin(cs_gpio_num); } +bool spicommon_bus_using_iomux(spi_host_device_t host) +{ +#define CHECK_IOMUX_PIN(HOST, PIN_NAME) if (GPIO.func_in_sel_cfg[spi_periph_signal[(HOST)].PIN_NAME##_in].sig_in_sel) return false + + CHECK_IOMUX_PIN(host, spid); + CHECK_IOMUX_PIN(host, spiq); + CHECK_IOMUX_PIN(host, spiwp); + CHECK_IOMUX_PIN(host, spihd); + return true; +} + /* Code for workaround for DMA issue in ESP32 v0/v1 silicon */