mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +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:
parent
db75d2c448
commit
e64cb619f7
@ -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));
|
||||
|
@ -37,6 +37,7 @@ extern "C" {
|
||||
typedef void (*voidFuncPtr)(void);
|
||||
|
||||
void initPins();
|
||||
void resetPins();
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
|
Loading…
x
Reference in New Issue
Block a user