mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
digitalWrite cleanup and more compliant with behavior on AVR
I rewrote digitalWrite because the existing version was breaking functionality as compared to how it behaves on the AVR,. specifically, I could not use digitalWrite for a library that works fine on the AVR. Instead I had to resort to fiddling with GPOC and GPOS and bit masks, but this rewrite made all of that unnecessary, for whatever reason, it just works better. This version borrows a little from the AVR library in the sense that the same logic is applied to determine whether a pin should be high or low as the AVR version, and yes, it does appear to make a difference.
This commit is contained in:
parent
e7b7d6d8b7
commit
c77f11906c
@ -77,13 +77,16 @@ extern void __pinMode(uint8_t pin, uint8_t mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern void ICACHE_RAM_ATTR __digitalWrite(uint8_t pin, uint8_t val) {
|
extern void ICACHE_RAM_ATTR __digitalWrite(uint8_t pin, uint8_t val) {
|
||||||
val &= 0x01;
|
if(val == LOW) {
|
||||||
if(pin < 16){
|
GP16O &= ~1;
|
||||||
if(val) GPOS = (1 << pin);
|
} else {
|
||||||
else GPOC = (1 << pin);
|
GP16O |= 1;
|
||||||
} else if(pin == 16){
|
}
|
||||||
if(val) GP16O |= 1;
|
if(val == LOW) {
|
||||||
else GP16O &= ~1;
|
GPOC = digitalPinToBitMask(pin);
|
||||||
|
} else {
|
||||||
|
GPOS = digitalPinToBitMask(pin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user