From 823c857d2c98d68c13b05efdc2a754191bcf7a51 Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Thu, 18 Jan 2024 11:53:42 +0530 Subject: [PATCH] [ESP32] Fix lock app factory reseting in a loop on ESP32C3 --- examples/lock-app/esp32/main/Button.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/lock-app/esp32/main/Button.cpp b/examples/lock-app/esp32/main/Button.cpp index b80e124523f893..2e3aafa4db2116 100644 --- a/examples/lock-app/esp32/main/Button.cpp +++ b/examples/lock-app/esp32/main/Button.cpp @@ -27,6 +27,14 @@ esp_err_t Button::Init(gpio_num_t gpioNum, uint16_t debouncePeriod) mState = false; mLastPolledState = false; + gpio_config_t io_conf = {}; + io_conf.intr_type = GPIO_INTR_NEGEDGE; + io_conf.pin_bit_mask = 1ULL << gpioNum; + io_conf.mode = GPIO_MODE_INPUT; + io_conf.pull_down_en = GPIO_PULLDOWN_ENABLE; + + gpio_config(&io_conf); + return gpio_set_direction(gpioNum, GPIO_MODE_INPUT); }