Skip to content

Commit f4c2135

Browse files
committed
RTC pins have pull up/down elsewhere
use driver/gpio for now. fixes: espressif#66
1 parent be2a26b commit f4c2135

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

cores/esp32/esp32-hal-gpio.c

+16-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "soc/gpio_reg.h"
2323
#include "soc/io_mux_reg.h"
2424
#include "soc/gpio_struct.h"
25+
#include "driver/gpio.h"
2526

2627
#define ETS_GPIO_INUM 4
2728

@@ -85,13 +86,6 @@ extern void IRAM_ATTR __pinMode(uint8_t pin, uint8_t mode)
8586
} else {
8687
GPIO.enable1_w1tc.val = ((uint32_t)1 << (pin - 32));
8788
}
88-
89-
if(mode & PULLUP) {
90-
pinFunction |= FUN_PU;
91-
} else if(mode & PULLDOWN) {
92-
pinFunction |= FUN_PD;
93-
}
94-
9589
} else if(mode & OUTPUT) {
9690
if(pin < 32) {
9791
GPIO.enable_w1ts = ((uint32_t)1 << pin);
@@ -111,11 +105,25 @@ extern void IRAM_ATTR __pinMode(uint8_t pin, uint8_t mode)
111105
pinFunction |= ((uint32_t)(mode >> 5) << MCU_SEL_S);
112106
}
113107

108+
ESP_REG(DR_REG_IO_MUX_BASE + esp32_gpioToFn[pin]) = pinFunction;
109+
110+
if((mode & INPUT) && (mode & (PULLUP|PULLDOWN))) {
111+
if(mode & PULLUP) {
112+
gpio_pullup_en(pin);
113+
gpio_pulldown_dis(pin);
114+
} else {
115+
gpio_pulldown_en(pin);
116+
gpio_pullup_dis(pin);
117+
}
118+
} else {
119+
gpio_pullup_dis(pin);
120+
gpio_pulldown_dis(pin);
121+
}
122+
114123
if(mode & OPEN_DRAIN) {
115124
pinControl = (1 << GPIO_PIN0_PAD_DRIVER_S);
116125
}
117126

118-
ESP_REG(DR_REG_IO_MUX_BASE + esp32_gpioToFn[pin]) = pinFunction;
119127
GPIO.pin[pin].val = pinControl;
120128
}
121129

0 commit comments

Comments
 (0)