Skip to content

Commit 0b14e44

Browse files
committed
add back pull-down support
1 parent 209b742 commit 0b14e44

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

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

+8-4
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,17 @@ extern void __pinMode(uint8_t pin, uint8_t mode) {
5959
GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO
6060
GPC(pin) = (GPC(pin) & (0xF << GPCI)); //SOURCE(GPIO) | DRIVER(NORMAL) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
6161
GPES = (1 << pin); //Enable
62-
} else if(mode == INPUT || mode == INPUT_PULLUP){
62+
} else if(mode == INPUT || mode == INPUT_PULLUP || mode == INPUT_PULLDOWN){
6363
GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO
6464
GPC(pin) = (GPC(pin) & (0xF << GPCI)) | (1 << GPCD); //SOURCE(GPIO) | DRIVER(OPEN_DRAIN) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
6565
GPEC = (1 << pin); //Disable
66-
if(mode == INPUT_PULLUP){
67-
GPF(pin) |= (1 << GPFPU);//Enable Pullup
68-
}
66+
if(mode == INPUT_PULLUP) {
67+
GPF(pin) &= ~(1 << GPFPD); // Disable Pulldown
68+
GPF(pin) |= (1 << GPFPU); // Enable Pullup
69+
} else if(mode == INPUT_PULLDOWN) {
70+
GPF(pin) &= ~(1 << GPFPU); // Disable Pullup
71+
GPF(pin) |= (1 << GPFPD); // Enable Pulldown
72+
}
6973
}
7074
} else if(pin == 16){
7175
GPF16 = GP16FFS(GPFFS_GPIO(pin));//Set mode to GPIO

hardware/esp8266com/esp8266/cores/esp8266/esp8266_peri.h

+2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ static uint8_t esp8266_gpioToFn[16] = {0x34, 0x18, 0x38, 0x14, 0x3C, 0x40, 0x1C,
9393
//GPIO (0-15) PIN Function Bits
9494
#define GPFSOE 0 //Sleep OE
9595
#define GPFSS 1 //Sleep Sel
96+
#define GPFSPD 2 //Sleep Pulldown
9697
#define GPFSPU 3 //Sleep Pullup
9798
#define GPFFS0 4 //Function Select bit 0
9899
#define GPFFS1 5 //Function Select bit 1
100+
#define GPFPD 6 //Pulldown
99101
#define GPFPU 7 //Pullup
100102
#define GPFFS2 8 //Function Select bit 2
101103
#define GPFFS(f) (((((f) & 4) != 0) << GPFFS2) | ((((f) & 2) != 0) << GPFFS1) | ((((f) & 1) != 0) << GPFFS0))

0 commit comments

Comments
 (0)