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:
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);
|
__attachInterruptFunctionalArg(pin, (voidFuncPtrArg)userFunc, 0, mode, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void initPins() {
|
extern void __resetPins() {
|
||||||
//Disable UART interrupts
|
|
||||||
system_set_os_print(0);
|
|
||||||
U0IE = 0;
|
|
||||||
U1IE = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i <= 5; ++i) {
|
for (int i = 0; i <= 5; ++i) {
|
||||||
pinMode(i, INPUT);
|
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 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 void digitalWrite(uint8_t pin, uint8_t val) __attribute__ ((weak, alias("__digitalWrite")));
|
||||||
extern int digitalRead(uint8_t pin) __attribute__ ((weak, alias("__digitalRead"), nothrow));
|
extern int digitalRead(uint8_t pin) __attribute__ ((weak, alias("__digitalRead"), nothrow));
|
||||||
|
@ -37,6 +37,7 @@ extern "C" {
|
|||||||
typedef void (*voidFuncPtr)(void);
|
typedef void (*voidFuncPtr)(void);
|
||||||
|
|
||||||
void initPins();
|
void initPins();
|
||||||
|
void resetPins();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user