fix(gpio): Avoid error message when calling reset on an input only pin

The `gpio_reset_pin` function attempted to enable internal pullup on pins which does not have one.
This change adds a guard to `gpio_reset_pin` for calling `gpio_pullup_en`
- the same guard that makes `gpio_pullup_en` print the error.
This commit is contained in:
Olivér Remény
2025-07-29 11:04:27 +02:00
committed by Song Ruo Jing
parent dddb4e5e58
commit ce6760c8bb

View File

@@ -441,11 +441,12 @@ esp_err_t gpio_config(const gpio_config_t *pGPIOConfig)
esp_err_t gpio_reset_pin(gpio_num_t gpio_num) esp_err_t gpio_reset_pin(gpio_num_t gpio_num)
{ {
assert(GPIO_IS_VALID_GPIO(gpio_num)); assert(GPIO_IS_VALID_GPIO(gpio_num));
bool pu_en = GPIO_IS_VALID_OUTPUT_GPIO(gpio_num);
gpio_config_t cfg = { gpio_config_t cfg = {
.pin_bit_mask = BIT64(gpio_num), .pin_bit_mask = BIT64(gpio_num),
.mode = GPIO_MODE_DISABLE, .mode = GPIO_MODE_DISABLE,
//for powersave reasons, the GPIO should not be floating, select pullup //for powersave reasons, the GPIO should not be floating, select pullup
.pull_up_en = true, .pull_up_en = pu_en,
.pull_down_en = false, .pull_down_en = false,
.intr_type = GPIO_INTR_DISABLE, .intr_type = GPIO_INTR_DISABLE,
}; };