]> granicus.if.org Git - esp-idf/commitdiff
spi_common: add interface to get whether the bus is on IOMUX
authorMichael (XIAO Xufeng) <xiaoxufeng@espressif.com>
Wed, 26 Jun 2019 03:42:02 +0000 (11:42 +0800)
committerMichael (XIAO Xufeng) <xiaoxufeng@espressif.com>
Thu, 27 Jun 2019 05:27:27 +0000 (13:27 +0800)
components/driver/include/driver/spi_common.h
components/driver/spi_common.c

index e038c63255130202641aa4cb6d5d0e93195b63ed..b4415954613f2c14b53f18059ac22fa9c4000afb 100644 (file)
@@ -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
  *
index 32d3442c1bb2c0a950bada15ae04aa7496608bcd..ff7501eafe7fc8775cbeaa0d2b1dcda8c3110049 100644 (file)
@@ -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
 */