1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Pull GPIO initialization into its own 'weak' function. (#7044)

* 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.

* Add prototype for resetPins()
This commit is contained in:
Clemens Kirchgatterer 2020-03-22 13:16:39 +01:00 committed by GitHub
parent db75d2c448
commit e64cb619f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -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));

View File

@ -37,6 +37,7 @@ extern "C" {
typedef void (*voidFuncPtr)(void);
void initPins();
void resetPins();
#ifdef __cplusplus
} // extern "C"