mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-03 18:40:59 +02:00
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:
committed by
Song Ruo Jing
parent
a6487d4a73
commit
a7e391d211
@@ -436,11 +436,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,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user