From a9a5a14a0bca20f45520fcc4bb2afe5e29e83a77 Mon Sep 17 00:00:00 2001 From: Deomid Ryabkov Date: Fri, 15 Dec 2017 18:43:04 +0300 Subject: [PATCH] Clear GPIO_PINn_INT_ENA on boot Soft reset does not clear thses fields, we have to do it ourselves, otherwise int can be triggered before handler is ready. h/t @kzyapkov Fixes https://github.com/cesanta/mongoose-os/issues/388 PUBLISHED_FROM=bf993c248f1ac992fc5b4df5d73819ca747657ce --- fw/platforms/esp32/src/esp32_gpio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fw/platforms/esp32/src/esp32_gpio.c b/fw/platforms/esp32/src/esp32_gpio.c index a1e0e7788..9ed00c96e 100644 --- a/fw/platforms/esp32/src/esp32_gpio.c +++ b/fw/platforms/esp32/src/esp32_gpio.c @@ -188,6 +188,10 @@ void (*mgos_nsleep100)(uint32_t n); uint32_t mgos_bitbang_n100_cal; enum mgos_init_result mgos_gpio_hal_init() { + /* Soft reset does not clear GPIO_PINn_INT_ENA, we have to do it ourselves. */ + for (int i = 0; i < MGOS_NUM_GPIO; i++) { + if (GPIO_IS_VALID_GPIO(i)) gpio_intr_disable(i); + } esp_err_t r = gpio_isr_register(esp32_gpio_isr, NULL, 0, &s_int_handle); if (r != ESP_OK) return MGOS_INIT_GPIO_INIT_FAILED; r = esp_intr_enable(s_int_handle);