Skip to content

Commit 4e41c23

Browse files
ficetoficeto
ficeto
authored and
ficeto
committed
add OUTPUT_OPEN_DRAIN
disabling pulls on pinMode is not needed, since they are cleared 2 lines above.
1 parent 3d01a6f commit 4e41c23

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

cores/esp8266/Arduino.h

+11-10
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,17 @@ void yield(void);
4747
#define PWMRANGE 1023
4848

4949
//GPIO FUNCTIONS
50-
#define INPUT 0x00
51-
#define OUTPUT 0x01
52-
#define INPUT_PULLUP 0x02
53-
#define INPUT_PULLDOWN 0x04
54-
#define SPECIAL 0xF8 //defaults to the usable BUSes uart0rx/tx uart1tx and hspi
55-
#define FUNCTION_0 0x08
56-
#define FUNCTION_1 0x18
57-
#define FUNCTION_2 0x28
58-
#define FUNCTION_3 0x38
59-
#define FUNCTION_4 0x48
50+
#define INPUT 0x00
51+
#define INPUT_PULLUP 0x02
52+
#define INPUT_PULLDOWN 0x04
53+
#define OUTPUT 0x01
54+
#define OUTPUT_OPEN_DRAIN 0x03
55+
#define SPECIAL 0xF8 //defaults to the usable BUSes uart0rx/tx uart1tx and hspi
56+
#define FUNCTION_0 0x08
57+
#define FUNCTION_1 0x18
58+
#define FUNCTION_2 0x28
59+
#define FUNCTION_3 0x38
60+
#define FUNCTION_4 0x48
6061

6162
#define PI 3.1415926535897932384626433832795
6263
#define HALF_PI 1.5707963267948966192313216916398

cores/esp8266/core_esp8266_wiring_digital.c

+8-9
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,20 @@ extern void __pinMode(uint8_t pin, uint8_t mode) {
3737
GPEC = (1 << pin); //Disable
3838
GPF(pin) = GPFFS((mode >> 4) & 0x07);
3939
if(pin == 13 && mode == FUNCTION_4) GPF(pin) |= (1 << GPFPU);//enable pullup on RX
40-
} else if(mode == OUTPUT){
40+
} else if(mode == OUTPUT || mode == OUTPUT_OPEN_DRAIN){
4141
GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO
4242
GPC(pin) = (GPC(pin) & (0xF << GPCI)); //SOURCE(GPIO) | DRIVER(NORMAL) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
43+
if(mode == OUTPUT_OPEN_DRAIN) GPC(pin) |= (1 << GPCD);
4344
GPES = (1 << pin); //Enable
4445
} else if(mode == INPUT || mode == INPUT_PULLUP || mode == INPUT_PULLDOWN){
4546
GPF(pin) = GPFFS(GPFFS_GPIO(pin));//Set mode to GPIO
46-
GPC(pin) = (GPC(pin) & (0xF << GPCI)) | (1 << GPCD); //SOURCE(GPIO) | DRIVER(OPEN_DRAIN) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
4747
GPEC = (1 << pin); //Disable
48-
if(mode == INPUT_PULLUP) {
49-
GPF(pin) &= ~(1 << GPFPD); // Disable Pulldown
50-
GPF(pin) |= (1 << GPFPU); // Enable Pullup
51-
} else if(mode == INPUT_PULLDOWN) {
52-
GPF(pin) &= ~(1 << GPFPU); // Disable Pullup
53-
GPF(pin) |= (1 << GPFPD); // Enable Pulldown
54-
}
48+
GPC(pin) = (GPC(pin) & (0xF << GPCI)) | (1 << GPCD); //SOURCE(GPIO) | DRIVER(OPEN_DRAIN) | INT_TYPE(UNCHANGED) | WAKEUP_ENABLE(DISABLED)
49+
if(mode == INPUT_PULLUP) {
50+
GPF(pin) |= (1 << GPFPU); // Enable Pullup
51+
} else if(mode == INPUT_PULLDOWN) {
52+
GPF(pin) |= (1 << GPFPD); // Enable Pulldown
53+
}
5554
}
5655
} else if(pin == 16){
5756
GPF16 = GP16FFS(GPFFS_GPIO(pin));//Set mode to GPIO

0 commit comments

Comments
 (0)