From ede7e8e1f485c4cbf0778786ad78fc2a4e61aba4 Mon Sep 17 00:00:00 2001 From: Clemens Kirchgatterer Date: Wed, 29 Jan 2020 17:27:11 +0100 Subject: [PATCH 1/2] Pull GPIO initialization into its own 'weak' function. By pulling GPIO init into its own weak function, it can be overridden by the user. This is important in cases when GPIOs should not toggle during reboot, exceptions or other crashes. Fixes #7041. --- cores/esp8266/core_esp8266_wiring_digital.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cores/esp8266/core_esp8266_wiring_digital.cpp b/cores/esp8266/core_esp8266_wiring_digital.cpp index 47eeebf862..a81cf069c2 100644 --- a/cores/esp8266/core_esp8266_wiring_digital.cpp +++ b/cores/esp8266/core_esp8266_wiring_digital.cpp @@ -235,12 +235,7 @@ extern void __attachInterrupt(uint8_t pin, voidFuncPtr userFunc, int mode) __attachInterruptFunctionalArg(pin, (voidFuncPtrArg)userFunc, 0, mode, false); } -extern void initPins() { - //Disable UART interrupts - system_set_os_print(0); - U0IE = 0; - U1IE = 0; - +extern void __resetPins() { for (int i = 0; i <= 5; ++i) { pinMode(i, INPUT); } @@ -250,6 +245,16 @@ extern void initPins() { } } +extern void initPins() { + //Disable UART interrupts + system_set_os_print(0); + U0IE = 0; + U1IE = 0; + + resetPins(); +} + +extern void resetPins() __attribute__ ((weak, alias("__resetPins"))); extern void pinMode(uint8_t pin, uint8_t mode) __attribute__ ((weak, alias("__pinMode"))); extern void digitalWrite(uint8_t pin, uint8_t val) __attribute__ ((weak, alias("__digitalWrite"))); extern int digitalRead(uint8_t pin) __attribute__ ((weak, alias("__digitalRead"), nothrow)); From 8ab77a4072479147a08ffb7bd40df5e1ec20ac23 Mon Sep 17 00:00:00 2001 From: Clemens Kirchgatterer Date: Thu, 19 Mar 2020 10:59:18 +0100 Subject: [PATCH 2/2] Add prototype for resetPins() --- cores/esp8266/wiring_private.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cores/esp8266/wiring_private.h b/cores/esp8266/wiring_private.h index 2c53565a67..cb52f05393 100644 --- a/cores/esp8266/wiring_private.h +++ b/cores/esp8266/wiring_private.h @@ -37,6 +37,7 @@ extern "C" { typedef void (*voidFuncPtr)(void); void initPins(); +void resetPins(); #ifdef __cplusplus } // extern "C"