mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-07 16:23:38 +03:00
add back pull-down support
This commit is contained in:
parent
0a712e78c7
commit
d4e6561b52
@ -59,13 +59,17 @@ extern void __pinMode(uint8_t pin, uint8_t mode) {
|
|||||||
GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO
|
GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO
|
||||||
GPC(pin) = (GPC(pin) & (0xF << GPCI)); //SOURCE(GPIO) | DRIVER(NORMAL) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
|
GPC(pin) = (GPC(pin) & (0xF << GPCI)); //SOURCE(GPIO) | DRIVER(NORMAL) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
|
||||||
GPES = (1 << pin); //Enable
|
GPES = (1 << pin); //Enable
|
||||||
} else if(mode == INPUT || mode == INPUT_PULLUP){
|
} else if(mode == INPUT || mode == INPUT_PULLUP || mode == INPUT_PULLDOWN){
|
||||||
GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO
|
GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO
|
||||||
GPC(pin) = (GPC(pin) & (0xF << GPCI)) | (1 << GPCD); //SOURCE(GPIO) | DRIVER(OPEN_DRAIN) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
|
GPC(pin) = (GPC(pin) & (0xF << GPCI)) | (1 << GPCD); //SOURCE(GPIO) | DRIVER(OPEN_DRAIN) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
|
||||||
GPEC = (1 << pin); //Disable
|
GPEC = (1 << pin); //Disable
|
||||||
if(mode == INPUT_PULLUP){
|
if(mode == INPUT_PULLUP) {
|
||||||
GPF(pin) |= (1 << GPFPU);//Enable Pullup
|
GPF(pin) &= ~(1 << GPFPD); // Disable Pulldown
|
||||||
}
|
GPF(pin) |= (1 << GPFPU); // Enable Pullup
|
||||||
|
} else if(mode == INPUT_PULLDOWN) {
|
||||||
|
GPF(pin) &= ~(1 << GPFPU); // Disable Pullup
|
||||||
|
GPF(pin) |= (1 << GPFPD); // Enable Pulldown
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if(pin == 16){
|
} else if(pin == 16){
|
||||||
GPF16 = GP16FFS(GPFFS_GPIO(pin));//Set mode to GPIO
|
GPF16 = GP16FFS(GPFFS_GPIO(pin));//Set mode to GPIO
|
||||||
|
@ -93,9 +93,11 @@ static uint8_t esp8266_gpioToFn[16] = {0x34, 0x18, 0x38, 0x14, 0x3C, 0x40, 0x1C,
|
|||||||
//GPIO (0-15) PIN Function Bits
|
//GPIO (0-15) PIN Function Bits
|
||||||
#define GPFSOE 0 //Sleep OE
|
#define GPFSOE 0 //Sleep OE
|
||||||
#define GPFSS 1 //Sleep Sel
|
#define GPFSS 1 //Sleep Sel
|
||||||
|
#define GPFSPD 2 //Sleep Pulldown
|
||||||
#define GPFSPU 3 //Sleep Pullup
|
#define GPFSPU 3 //Sleep Pullup
|
||||||
#define GPFFS0 4 //Function Select bit 0
|
#define GPFFS0 4 //Function Select bit 0
|
||||||
#define GPFFS1 5 //Function Select bit 1
|
#define GPFFS1 5 //Function Select bit 1
|
||||||
|
#define GPFPD 6 //Pulldown
|
||||||
#define GPFPU 7 //Pullup
|
#define GPFPU 7 //Pullup
|
||||||
#define GPFFS2 8 //Function Select bit 2
|
#define GPFFS2 8 //Function Select bit 2
|
||||||
#define GPFFS(f) (((((f) & 4) != 0) << GPFFS2) | ((((f) & 2) != 0) << GPFFS1) | ((((f) & 1) != 0) << GPFFS0))
|
#define GPFFS(f) (((((f) & 4) != 0) << GPFFS2) | ((((f) & 2) != 0) << GPFFS1) | ((((f) & 1) != 0) << GPFFS0))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user