From 4c16d3caa8384e1cc59450ef5240a19346e8fe4c Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 9 Jan 2020 18:15:43 +0100 Subject: [PATCH] Interupts are not always cleared after soft reset (notably GPIO2) --- platforms/esp8266/src/esp_gpio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platforms/esp8266/src/esp_gpio.c b/platforms/esp8266/src/esp_gpio.c index 60ee230f9..137cc066f 100644 --- a/platforms/esp8266/src/esp_gpio.c +++ b/platforms/esp8266/src/esp_gpio.c @@ -207,6 +207,12 @@ void (*mgos_nsleep100)(uint32_t n); uint32_t mgos_bitbang_n100_cal; enum mgos_init_result mgos_gpio_hal_init(void) { + // Interupts are not alaway cleared after soft reset (notably GPIO2) + // Probably the GPIO2 is triggered because of the second UART - U1TXD, + // which is transmitting data during boot. Clear everything + for (int i = 0; i < GPIO_PIN_COUNT; i++) { + mgos_gpio_hal_clear_int(i); + } #ifdef RTOS_SDK _xt_isr_attach(ETS_GPIO_INUM, (void *) esp8266_gpio_isr, NULL); _xt_isr_unmask(1 << ETS_GPIO_INUM);