mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-01 06:27:29 +00:00
feat(gpio): add gpio_config_as_analog API
This commit is contained in:
@@ -433,6 +433,26 @@ esp_err_t gpio_config(const gpio_config_t *pGPIOConfig)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t gpio_config_as_analog(gpio_num_t gpio_num)
|
||||
{
|
||||
GPIO_CHECK(GPIO_IS_VALID_GPIO(gpio_num), "GPIO number error", ESP_ERR_INVALID_ARG);
|
||||
// To be used for analog function, the pin needs to be left floating
|
||||
gpio_input_disable(gpio_num);
|
||||
gpio_output_disable(gpio_num);
|
||||
gpio_pullup_dis(gpio_num);
|
||||
gpio_pulldown_dis(gpio_num);
|
||||
gpio_hal_func_sel(gpio_context.gpio_hal, gpio_num, PIN_FUNC_GPIO);
|
||||
#if SOC_RTCIO_INPUT_OUTPUT_SUPPORTED
|
||||
if (rtc_gpio_is_valid_gpio(gpio_num)) {
|
||||
rtc_gpio_deinit(gpio_num);
|
||||
rtc_gpio_set_direction(gpio_num, RTC_GPIO_MODE_DISABLED);
|
||||
rtc_gpio_pullup_dis(gpio_num);
|
||||
rtc_gpio_pulldown_dis(gpio_num);
|
||||
}
|
||||
#endif
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t gpio_reset_pin(gpio_num_t gpio_num)
|
||||
{
|
||||
assert(GPIO_IS_VALID_GPIO(gpio_num));
|
||||
|
@@ -239,8 +239,10 @@ esp_err_t rtc_gpio_force_hold_dis_all(void)
|
||||
esp_err_t rtc_gpio_isolate(gpio_num_t gpio_num)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(rtc_gpio_is_valid_gpio(gpio_num), ESP_ERR_INVALID_ARG, RTCIO_TAG, "RTCIO number error");
|
||||
int rtcio_num = rtc_io_number_get(gpio_num);
|
||||
RTCIO_ENTER_CRITICAL();
|
||||
rtcio_hal_isolate(rtc_io_number_get(gpio_num));
|
||||
rtcio_hal_isolate(rtcio_num);
|
||||
rtcio_hal_hold_enable(rtcio_num);
|
||||
RTCIO_EXIT_CRITICAL();
|
||||
|
||||
return ESP_OK;
|
||||
|
Reference in New Issue
Block a user