File tree 1 file changed +16
-8
lines changed
1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change 22
22
#include "soc/gpio_reg.h"
23
23
#include "soc/io_mux_reg.h"
24
24
#include "soc/gpio_struct.h"
25
+ #include "driver/gpio.h"
25
26
26
27
#define ETS_GPIO_INUM 4
27
28
@@ -85,13 +86,6 @@ extern void IRAM_ATTR __pinMode(uint8_t pin, uint8_t mode)
85
86
} else {
86
87
GPIO .enable1_w1tc .val = ((uint32_t )1 << (pin - 32 ));
87
88
}
88
-
89
- if (mode & PULLUP ) {
90
- pinFunction |= FUN_PU ;
91
- } else if (mode & PULLDOWN ) {
92
- pinFunction |= FUN_PD ;
93
- }
94
-
95
89
} else if (mode & OUTPUT ) {
96
90
if (pin < 32 ) {
97
91
GPIO .enable_w1ts = ((uint32_t )1 << pin );
@@ -111,11 +105,25 @@ extern void IRAM_ATTR __pinMode(uint8_t pin, uint8_t mode)
111
105
pinFunction |= ((uint32_t )(mode >> 5 ) << MCU_SEL_S );
112
106
}
113
107
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
+
114
123
if (mode & OPEN_DRAIN ) {
115
124
pinControl = (1 << GPIO_PIN0_PAD_DRIVER_S );
116
125
}
117
126
118
- ESP_REG (DR_REG_IO_MUX_BASE + esp32_gpioToFn [pin ]) = pinFunction ;
119
127
GPIO .pin [pin ].val = pinControl ;
120
128
}
121
129
You can’t perform that action at this time.
0 commit comments