Skip to content

Commit

Permalink
add config to disable gpio button internal pull
Browse files Browse the repository at this point in the history
  • Loading branch information
dengber committed Dec 15, 2024
1 parent f5ca5b5 commit 0997e9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions components/button/button_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions components/button/include/button_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down

0 comments on commit 0997e9a

Please sign in to comment.