Skip to content

Commit bbd6791

Browse files
dengberleeebo
authored andcommitted
feat: add config to disable gpio button internal pull
close #447
1 parent f5ca5b5 commit bbd6791

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

components/button/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ChangeLog
22

3+
## v3.5.0 - 2024-12-27
4+
5+
### Enhancements:
6+
7+
* Add config to disable gpio button internal pull resistor.
8+
39
## v3.4.1 - 2024-12-6
410

511
### Fix:

components/button/button_gpio.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
1+
/* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
22
*
33
* SPDX-License-Identifier: Apache-2.0
44
*/
@@ -26,12 +26,17 @@ esp_err_t button_gpio_init(const button_gpio_config_t *config)
2626
gpio_conf.intr_type = GPIO_INTR_DISABLE;
2727
gpio_conf.mode = GPIO_MODE_INPUT;
2828
gpio_conf.pin_bit_mask = (1ULL << config->gpio_num);
29-
if (config->active_level) {
30-
gpio_conf.pull_down_en = GPIO_PULLDOWN_ENABLE;
29+
if (config->disable_pull) {
30+
gpio_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
3131
gpio_conf.pull_up_en = GPIO_PULLUP_DISABLE;
3232
} else {
33-
gpio_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
34-
gpio_conf.pull_up_en = GPIO_PULLUP_ENABLE;
33+
if (config->active_level) {
34+
gpio_conf.pull_down_en = GPIO_PULLDOWN_ENABLE;
35+
gpio_conf.pull_up_en = GPIO_PULLUP_DISABLE;
36+
} else {
37+
gpio_conf.pull_down_en = GPIO_PULLDOWN_DISABLE;
38+
gpio_conf.pull_up_en = GPIO_PULLUP_ENABLE;
39+
}
3540
}
3641
gpio_config(&gpio_conf);
3742

components/button/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "3.4.1"
1+
version: "3.5.0"
22
description: GPIO and ADC button driver
33
url: https://github.com/espressif/esp-iot-solution/tree/master/components/button
44
repository: https://github.com/espressif/esp-iot-solution.git

components/button/include/button_gpio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ typedef struct {
2121
#if CONFIG_GPIO_BUTTON_SUPPORT_POWER_SAVE
2222
bool enable_power_save; /**< enable power save mode */
2323
#endif
24+
bool disable_pull; /**< disable internal pull or not */
2425
} button_gpio_config_t;
2526

2627
/**

0 commit comments

Comments
 (0)