}
return ESP_OK;
}
+
+static const uint32_t GPIO_HOLD_MASK[34] = {
+ 0,
+ GPIO_SEL_1,
+ 0,
+ GPIO_SEL_0,
+ 0,
+ GPIO_SEL_8,
+ GPIO_SEL_2,
+ GPIO_SEL_3,
+ GPIO_SEL_4,
+ GPIO_SEL_5,
+ GPIO_SEL_6,
+ GPIO_SEL_7,
+ 0,
+ 0,
+ 0,
+ 0,
+ GPIO_SEL_9,
+ GPIO_SEL_10,
+ GPIO_SEL_11,
+ GPIO_SEL_12,
+ 0,
+ GPIO_SEL_14,
+ GPIO_SEL_15,
+ GPIO_SEL_16,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+esp_err_t gpio_hold_en(gpio_num_t gpio_num)
+{
+ GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "Only output-capable GPIO support this function", ESP_ERR_NOT_SUPPORTED);
+ esp_err_t r = ESP_OK;
+ if (RTC_GPIO_IS_VALID_GPIO(gpio_num)) {
+ r = rtc_gpio_hold_en(gpio_num);
+ } else if (GPIO_HOLD_MASK[gpio_num]) {
+ SET_PERI_REG_MASK(RTC_IO_DIG_PAD_HOLD_REG, GPIO_HOLD_MASK[gpio_num]);
+ } else {
+ r = ESP_ERR_NOT_SUPPORTED;
+ }
+ return r == ESP_OK ? ESP_OK : ESP_ERR_NOT_SUPPORTED;
+}
+
+esp_err_t gpio_hold_dis(gpio_num_t gpio_num)
+{
+ GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "Only output-capable GPIO support this function", ESP_ERR_NOT_SUPPORTED);
+ esp_err_t r = ESP_OK;
+ if (RTC_GPIO_IS_VALID_GPIO(gpio_num)) {
+ r = rtc_gpio_hold_dis(gpio_num);
+ } else if (GPIO_HOLD_MASK[gpio_num]) {
+ CLEAR_PERI_REG_MASK(RTC_IO_DIG_PAD_HOLD_REG, GPIO_HOLD_MASK[gpio_num]);
+ } else {
+ r = ESP_ERR_NOT_SUPPORTED;
+ }
+ return r == ESP_OK ? ESP_OK : ESP_ERR_NOT_SUPPORTED;
+}
\ No newline at end of file
*/
esp_err_t gpio_get_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t* strength);
+/**
+ * @brief Set gpio pad hold function.
+ *
+ * The gpio pad hold function works in both input and output modes, but must be output-capable gpios.
+ * If pad hold enabled:
+ * in output mode: the output level of the pad will be force locked and can not be changed.
+ * in input mode: the input value read will not change, regardless the changes of input signal.
+ *
+ * Power down or call gpio_hold_dis will disable this function.
+ *
+ * @param gpio_num GPIO number, only support output-capable GPIOs
+ *
+ * @return
+ * - ESP_OK Success
+ * - ESP_ERR_NOT_SUPPORTED Not support pad hold function
+ */
+esp_err_t gpio_hold_en(gpio_num_t gpio_num);
+
+/**
+ * @brief Unset gpio pad hold function.
+ *
+ * @param gpio_num GPIO number, only support output-capable GPIOs
+ *
+ * @return
+ * - ESP_OK Success
+ * - ESP_ERR_NOT_SUPPORTED Not support pad hold function
+ */
+ esp_err_t gpio_hold_dis(gpio_num_t gpio_num);
+
#ifdef __cplusplus
}
#endif