提交 917a4fd6 编写于 作者: M me-no-dev

allow setting internal pull resistors for any mode and enable them for I2C

上级 c19fc061
......@@ -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?
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册