Skip to content

Commit a194024

Browse files
committed
Add wakeup pullup and pulldown pin modes
1 parent 69e9f2e commit a194024

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

hardware/esp8266com/esp8266/cores/esp8266/Arduino.h

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ void yield(void);
5151
#define INPUT_PULLDOWN 0x04
5252
#define OUTPUT 0x01
5353
#define OUTPUT_OPEN_DRAIN 0x03
54+
#define WAKEUP_PULLUP 0x05
55+
#define WAKEUP_PULLDOWN 0x07
5456
#define SPECIAL 0xF8 //defaults to the usable BUSes uart0rx/tx uart1tx and hspi
5557
#define FUNCTION_0 0x08
5658
#define FUNCTION_1 0x18

hardware/esp8266com/esp8266/cores/esp8266/core_esp8266_wiring_digital.c

+10
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ extern void __pinMode(uint8_t pin, uint8_t mode) {
5353
} else if(mode == INPUT_PULLDOWN) {
5454
GPF(pin) |= (1 << GPFPD); // Enable Pulldown
5555
}
56+
} else if(mode == WAKEUP_PULLUP || mode == WAKEUP_PULLDOWN){
57+
GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO
58+
GPEC = (1 << pin); //Disable
59+
if(mode == WAKEUP_PULLUP) {
60+
GPF(pin) |= (1 << GPFPU); // Enable Pullup
61+
GPC(pin) = (1 << GPCD) | (4 << GPCI) | (1 << GPCWE); //SOURCE(GPIO) | DRIVER(OPEN_DRAIN) | INT_TYPE(LOW) | WAKEUP_ENABLE(ENABLED)
62+
} else {
63+
GPF(pin) |= (1 << GPFPD); // Enable Pulldown
64+
GPC(pin) = (1 << GPCD) | (5 << GPCI) | (1 << GPCWE); //SOURCE(GPIO) | DRIVER(OPEN_DRAIN) | INT_TYPE(HIGH) | WAKEUP_ENABLE(ENABLED)
65+
}
5666
}
5767
} else if(pin == 16){
5868
GPF16 = GP16FFS(GPFFS_GPIO(pin));//Set mode to GPIO

0 commit comments

Comments
 (0)