gpio: add `gpio_pin_is_input_dt` and `gpio_pin_is_output_dt` helpers
Add helpers to allow providing a `struct gpio_dt_spec` directly
to `gpio_pin_is_input` and `gpio_pin_is_output` functions.
@@ -816,6 +816,22 @@ static inline int gpio_pin_is_input(const struct device *port, gpio_pin_t pin)
return (int)!!((gpio_port_pins_t)BIT(pin) & pins);
}
+/**
+ * @brief Check if a single pin from @p gpio_dt_spec is configured for input
+ *
+ * This is equivalent to:
+ *
+ * gpio_pin_is_input(spec->port, spec->pin);
+ *
+ * @param spec GPIO specification from devicetree.
+ *
+ * @return A value from gpio_pin_is_input().
+ */
+static inline int gpio_pin_is_input_dt(const struct gpio_dt_spec *spec)
+{
+ return gpio_pin_is_input(spec->port, spec->pin);
+}
+
/**
* @brief Check if @p pin is configured for output
*
@@ -845,6 +861,22 @@ static inline int gpio_pin_is_output(const struct device *port, gpio_pin_t pin)
return (int)!!((gpio_port_pins_t)BIT(pin) & pins);
}
+/**
+ * @brief Check if a single pin from @p gpio_dt_spec is configured for output
+ *
+ * This is equivalent to:
+ *
+ * gpio_pin_is_output(spec->port, spec->pin);
+ *
+ * @param spec GPIO specification from devicetree.
+ *
+ * @return A value from gpio_pin_is_output().
+ */
+static inline int gpio_pin_is_output_dt(const struct gpio_dt_spec *spec)
+{
+ return gpio_pin_is_output(spec->port, spec->pin);
+}
+
/**
* @brief Get a configuration of a single pin.
*
