diff --git a/components/button/button_gpio.c b/components/button/button_gpio.c index 097f0e718..33132a491 100644 --- a/components/button/button_gpio.c +++ b/components/button/button_gpio.c @@ -26,12 +26,17 @@ esp_err_t button_gpio_init(const button_gpio_config_t *config) gpio_conf.intr_type = GPIO_INTR_DISABLE; gpio_conf.mode = GPIO_MODE_INPUT; gpio_conf.pin_bit_mask = (1ULL << config->gpio_num); - if (config->active_level) { - gpio_conf.pull_down_en = GPIO_PULLDOWN_ENABLE; - gpio_conf.pull_up_en = GPIO_PULLUP_DISABLE; + if(config->disable_pull) { + gpio_conf.pull_down_en = GPIO_PULLDOWN_DISABLE; + gpio_conf.pull_up_en = GPIO_PULLUP_DISABLE; } else { - gpio_conf.pull_down_en = GPIO_PULLDOWN_DISABLE; - gpio_conf.pull_up_en = GPIO_PULLUP_ENABLE; + if (config->active_level) { + gpio_conf.pull_down_en = GPIO_PULLDOWN_ENABLE; + gpio_conf.pull_up_en = GPIO_PULLUP_DISABLE; + } else { + gpio_conf.pull_down_en = GPIO_PULLDOWN_DISABLE; + gpio_conf.pull_up_en = GPIO_PULLUP_ENABLE; + } } gpio_config(&gpio_conf); diff --git a/components/button/include/button_gpio.h b/components/button/include/button_gpio.h index e4b44d89f..429392f26 100644 --- a/components/button/include/button_gpio.h +++ b/components/button/include/button_gpio.h @@ -21,6 +21,7 @@ typedef struct { #if CONFIG_GPIO_BUTTON_SUPPORT_POWER_SAVE bool enable_power_save; /**< enable power save mode */ #endif + bool disable_pull; /**< disable internal pull or not */ } button_gpio_config_t; /**