mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-25 20:02:37 +03:00
add OUTPUT_OPEN_DRAIN
disabling pulls on pinMode is not needed, since they are cleared 2 lines above.
This commit is contained in:
parent
3d01a6f16d
commit
4e41c2399b
@ -47,16 +47,17 @@ void yield(void);
|
|||||||
#define PWMRANGE 1023
|
#define PWMRANGE 1023
|
||||||
|
|
||||||
//GPIO FUNCTIONS
|
//GPIO FUNCTIONS
|
||||||
#define INPUT 0x00
|
#define INPUT 0x00
|
||||||
#define OUTPUT 0x01
|
#define INPUT_PULLUP 0x02
|
||||||
#define INPUT_PULLUP 0x02
|
#define INPUT_PULLDOWN 0x04
|
||||||
#define INPUT_PULLDOWN 0x04
|
#define OUTPUT 0x01
|
||||||
#define SPECIAL 0xF8 //defaults to the usable BUSes uart0rx/tx uart1tx and hspi
|
#define OUTPUT_OPEN_DRAIN 0x03
|
||||||
#define FUNCTION_0 0x08
|
#define SPECIAL 0xF8 //defaults to the usable BUSes uart0rx/tx uart1tx and hspi
|
||||||
#define FUNCTION_1 0x18
|
#define FUNCTION_0 0x08
|
||||||
#define FUNCTION_2 0x28
|
#define FUNCTION_1 0x18
|
||||||
#define FUNCTION_3 0x38
|
#define FUNCTION_2 0x28
|
||||||
#define FUNCTION_4 0x48
|
#define FUNCTION_3 0x38
|
||||||
|
#define FUNCTION_4 0x48
|
||||||
|
|
||||||
#define PI 3.1415926535897932384626433832795
|
#define PI 3.1415926535897932384626433832795
|
||||||
#define HALF_PI 1.5707963267948966192313216916398
|
#define HALF_PI 1.5707963267948966192313216916398
|
||||||
|
@ -37,21 +37,20 @@ extern void __pinMode(uint8_t pin, uint8_t mode) {
|
|||||||
GPEC = (1 << pin); //Disable
|
GPEC = (1 << pin); //Disable
|
||||||
GPF(pin) = GPFFS((mode >> 4) & 0x07);
|
GPF(pin) = GPFFS((mode >> 4) & 0x07);
|
||||||
if(pin == 13 && mode == FUNCTION_4) GPF(pin) |= (1 << GPFPU);//enable pullup on RX
|
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
|
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)
|
||||||
|
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 || 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)
|
|
||||||
GPEC = (1 << pin); //Disable
|
GPEC = (1 << pin); //Disable
|
||||||
if(mode == INPUT_PULLUP) {
|
GPC(pin) = (GPC(pin) & (0xF << GPCI)) | (1 << GPCD); //SOURCE(GPIO) | DRIVER(OPEN_DRAIN) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
|
||||||
GPF(pin) &= ~(1 << GPFPD); // Disable Pulldown
|
if(mode == INPUT_PULLUP) {
|
||||||
GPF(pin) |= (1 << GPFPU); // Enable Pullup
|
GPF(pin) |= (1 << GPFPU); // Enable Pullup
|
||||||
} else if(mode == INPUT_PULLDOWN) {
|
} else if(mode == INPUT_PULLDOWN) {
|
||||||
GPF(pin) &= ~(1 << GPFPU); // Disable Pullup
|
GPF(pin) |= (1 << GPFPD); // Enable Pulldown
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user