diff --git a/cores/esp32/esp32-hal-gpio.c b/cores/esp32/esp32-hal-gpio.c index 2698d33f..6b2f9cc8 100644 --- a/cores/esp32/esp32-hal-gpio.c +++ b/cores/esp32/esp32-hal-gpio.c @@ -103,7 +103,10 @@ extern void IRAM_ATTR __pinMode(uint8_t pin, uint8_t mode) //unlock rtc ESP_REG(DR_REG_IO_MUX_BASE + esp32_gpioMux[pin].reg) = ((uint32_t)2 << MCU_SEL_S) | ((uint32_t)2 << FUN_DRV_S) | FUN_IE; return; - } else if(rtc_reg) { + } + + //RTC pins PULL settings + if(rtc_reg) { //lock rtc ESP_REG(rtc_reg) = ESP_REG(rtc_reg) & ~(rtc_gpio_desc[pin].mux); if(mode & PULLUP) { @@ -125,12 +128,6 @@ extern void IRAM_ATTR __pinMode(uint8_t pin, uint8_t mode) } else { GPIO.enable1_w1tc.val = ((uint32_t)1 << (pin - 32)); } - - if(mode & PULLUP) { - pinFunction |= FUN_PU; - } else if(mode & PULLDOWN) { - pinFunction |= FUN_PD; - } } else if(mode & OUTPUT) { if(pin > 33){ //unlock gpio @@ -142,6 +139,12 @@ extern void IRAM_ATTR __pinMode(uint8_t pin, uint8_t mode) } } + if(mode & PULLUP) { + pinFunction |= FUN_PU; + } else if(mode & PULLDOWN) { + pinFunction |= FUN_PD; + } + pinFunction |= ((uint32_t)2 << FUN_DRV_S);//what are the drivers? pinFunction |= FUN_IE;//input enable but required for output as well? diff --git a/cores/esp32/esp32-hal-i2c.c b/cores/esp32/esp32-hal-i2c.c index 4871248c..d11add60 100644 --- a/cores/esp32/esp32-hal-i2c.c +++ b/cores/esp32/esp32-hal-i2c.c @@ -67,7 +67,7 @@ i2c_err_t i2cAttachSCL(i2c_t * i2c, int8_t scl) if(i2c == NULL){ return I2C_ERROR_DEV; } - pinMode(scl, OUTPUT_OPEN_DRAIN); + pinMode(scl, OUTPUT_OPEN_DRAIN | PULLUP); pinMatrixOutAttach(scl, I2C_SCL_IDX(i2c->num), false, false); pinMatrixInAttach(scl, I2C_SCL_IDX(i2c->num), false); return I2C_ERROR_OK; @@ -89,7 +89,7 @@ i2c_err_t i2cAttachSDA(i2c_t * i2c, int8_t sda) if(i2c == NULL){ return I2C_ERROR_DEV; } - pinMode(sda, OUTPUT_OPEN_DRAIN); + pinMode(sda, OUTPUT_OPEN_DRAIN | PULLUP); pinMatrixOutAttach(sda, I2C_SDA_IDX(i2c->num), false, false); pinMatrixInAttach(sda, I2C_SDA_IDX(i2c->num), false); return I2C_ERROR_OK;