1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Pulldown only possible for in 16. ( see #478 )

rename define to INPUT_PULLDOWN_16 to make it clear
This commit is contained in:
Markus Sattler 2015-07-01 17:56:19 +02:00 committed by Ivan Grokhotkov
parent 715d4ab722
commit ddf03fc92b
2 changed files with 4 additions and 6 deletions

View File

@ -48,7 +48,7 @@ void yield(void);
//GPIO FUNCTIONS //GPIO FUNCTIONS
#define INPUT 0x00 #define INPUT 0x00
#define INPUT_PULLUP 0x02 #define INPUT_PULLUP 0x02
#define INPUT_PULLDOWN 0x04 #define INPUT_PULLDOWN_16 0x04 // PULLDOWN only possible for pin16
#define OUTPUT 0x01 #define OUTPUT 0x01
#define OUTPUT_OPEN_DRAIN 0x03 #define OUTPUT_OPEN_DRAIN 0x03
#define WAKEUP_PULLUP 0x05 #define WAKEUP_PULLUP 0x05

View File

@ -44,14 +44,12 @@ extern void __pinMode(uint8_t pin, uint8_t mode) {
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)
if(mode == OUTPUT_OPEN_DRAIN) GPC(pin) |= (1 << GPCD); if(mode == OUTPUT_OPEN_DRAIN) GPC(pin) |= (1 << GPCD);
GPES = (1 << pin); //Enable GPES = (1 << pin); //Enable
} else if(mode == INPUT || mode == INPUT_PULLUP || mode == INPUT_PULLDOWN){ } else if(mode == INPUT || mode == INPUT_PULLUP){
GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO
GPEC = (1 << pin); //Disable GPEC = (1 << pin); //Disable
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)
if(mode == INPUT_PULLUP) { if(mode == INPUT_PULLUP) {
GPF(pin) |= (1 << GPFPU); // Enable Pullup GPF(pin) |= (1 << GPFPU); // Enable Pullup
} else if(mode == INPUT_PULLDOWN) {
GPF(pin) |= (1 << GPFPD); // Enable Pulldown
} }
} else if(mode == WAKEUP_PULLUP || mode == WAKEUP_PULLDOWN){ } else if(mode == WAKEUP_PULLUP || mode == WAKEUP_PULLDOWN){
GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO
@ -67,8 +65,8 @@ extern void __pinMode(uint8_t pin, uint8_t mode) {
} 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
GPC16 = 0; GPC16 = 0;
if(mode == INPUT || mode == INPUT_PULLDOWN){ if(mode == INPUT || mode == INPUT_PULLDOWN_16){
if(mode == INPUT_PULLDOWN){ if(mode == INPUT_PULLDOWN_16){
GPF16 |= (1 << GP16FPD);//Enable Pulldown GPF16 |= (1 << GP16FPD);//Enable Pulldown
} }
GP16E &= ~1; GP16E &= ~1;