Skip to content

Commit 0ea23fe

Browse files
committed
Update esp32-hal-gpio.c
1 parent 7f56028 commit 0ea23fe

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

cores/esp32/esp32-hal-gpio.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,39 @@ static InterruptHandle_t __pinInterruptHandlers[GPIO_PIN_COUNT] = {0,};
154154

155155
#include "driver/rtc_io.h"
156156

157+
//
158+
//static void idf_pinMode(uint8_t pin, uint8_t mode)
159+
//{
160+
// gpio_mode_t m = 0;
161+
// if(mode & INPUT) {
162+
// m |= GPIO_MODE_DEF_INPUT;
163+
// }
164+
// if(mode & OUTPUT) {
165+
// m |= GPIO_MODE_DEF_OUTPUT;
166+
// }
167+
// if(mode & OPEN_DRAIN) {
168+
// m |= GPIO_MODE_DEF_OD;
169+
// }
170+
// gpio_config_t conf = {
171+
// .pin_bit_mask = 1LL << pin,
172+
// .mode = (gpio_mode_t)m,
173+
// .pull_up_en = (gpio_pullup_t)((mode & PULLUP) != 0),
174+
// .pull_down_en = (gpio_pulldown_t)((mode & PULLDOWN) != 0),
175+
// .intr_type = (gpio_int_type_t)GPIO_INTR_DISABLE
176+
// };
177+
// gpio_config(&conf);
178+
//}
179+
180+
157181
extern void IRAM_ATTR __pinMode(uint8_t pin, uint8_t mode)
158182
{
159183

160184
if(!digitalPinIsValid(pin)) {
161185
return;
162186
}
163187

188+
//return idf_pinMode(pin, mode);
189+
164190
uint32_t rtc_reg = rtc_io_desc[pin].reg;
165191
if(mode == ANALOG) {
166192
if(!rtc_reg) {
@@ -227,9 +253,17 @@ extern void IRAM_ATTR __pinMode(uint8_t pin, uint8_t mode)
227253
pinFunction |= FUN_IE;//input enable but required for output as well?
228254

229255
if(mode & (INPUT | OUTPUT)) {
256+
#if CONFIG_IDF_TARGET_ESP32
230257
pinFunction |= ((uint32_t)2 << MCU_SEL_S);
258+
#elif CONFIG_IDF_TARGET_ESP32S2
259+
pinFunction |= ((uint32_t)1 << MCU_SEL_S);
260+
#endif
231261
} else if(mode == SPECIAL) {
232-
pinFunction |= ((uint32_t)(((pin)==1||(pin)==3)?0:1) << MCU_SEL_S);
262+
#if CONFIG_IDF_TARGET_ESP32
263+
pinFunction |= ((uint32_t)(((pin)==RX||(pin)==TX)?0:1) << MCU_SEL_S);
264+
#elif CONFIG_IDF_TARGET_ESP32S2
265+
pinFunction |= ((uint32_t)(((pin)==RX||(pin)==TX)?0:2) << MCU_SEL_S);
266+
#endif
233267
} else {
234268
pinFunction |= ((uint32_t)(mode >> 5) << MCU_SEL_S);
235269
}

0 commit comments

Comments
 (0)