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

Merge pull request #176 from ficeto/esp8266

add OUTPUT_OPEN_DRAIN
This commit is contained in:
Ivan Grokhotkov 2015-05-05 13:10:36 +03:00
commit ec8110b78c
2 changed files with 19 additions and 19 deletions

View File

@ -48,9 +48,10 @@ void yield(void);
//GPIO FUNCTIONS
#define INPUT 0x00
#define OUTPUT 0x01
#define INPUT_PULLUP 0x02
#define INPUT_PULLDOWN 0x04
#define OUTPUT 0x01
#define OUTPUT_OPEN_DRAIN 0x03
#define SPECIAL 0xF8 //defaults to the usable BUSes uart0rx/tx uart1tx and hspi
#define FUNCTION_0 0x08
#define FUNCTION_1 0x18

View File

@ -37,19 +37,18 @@ extern void __pinMode(uint8_t pin, uint8_t mode) {
GPEC = (1 << pin); //Disable
GPF(pin) = GPFFS((mode >> 4) & 0x07);
if(pin == 13 && mode == FUNCTION_4) GPF(pin) |= (1 << GPFPU);//enable pullup on RX
} else if(mode == OUTPUT){
} else if(mode == OUTPUT || mode == OUTPUT_OPEN_DRAIN){
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)
if(mode == OUTPUT_OPEN_DRAIN) GPC(pin) |= (1 << GPCD);
GPES = (1 << pin); //Enable
} else if(mode == INPUT || mode == INPUT_PULLUP || mode == INPUT_PULLDOWN){
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)
GPEC = (1 << pin); //Disable
GPC(pin) = (GPC(pin) & (0xF << GPCI)) | (1 << GPCD); //SOURCE(GPIO) | DRIVER(OPEN_DRAIN) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
if(mode == INPUT_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
}
}