Skip to content

Commit

Permalink
Merge branch 'bugfix/rtc_i2c_not_in_od_mode_v5.2' into 'release/v5.2'
Browse files Browse the repository at this point in the history
fix(ulp_riscv): Updated RTC I2C to use open-drain IOs (v5.2)

See merge request espressif/esp-idf!28931
  • Loading branch information
ESP-Marius committed Feb 18, 2024
2 parents 709d8ef + b8139a6 commit 2c0d846
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion components/ulp/ulp_riscv/ulp_riscv_i2c.c
Expand Up @@ -72,7 +72,7 @@ static esp_err_t i2c_configure_io(gpio_num_t io_num, bool pullup_en)
/* Initialize IO Pin */
ESP_RETURN_ON_ERROR(rtc_gpio_init(io_num), RTCI2C_TAG, "RTC GPIO Init failed for GPIO %d", io_num);
/* Set direction to input+output */
ESP_RETURN_ON_ERROR(rtc_gpio_set_direction(io_num, RTC_GPIO_MODE_INPUT_OUTPUT), RTCI2C_TAG, "RTC GPIO Set direction failed for %d", io_num);
ESP_RETURN_ON_ERROR(rtc_gpio_set_direction(io_num, RTC_GPIO_MODE_INPUT_OUTPUT_OD), RTCI2C_TAG, "RTC GPIO Set direction failed for %d", io_num);
/* Disable pulldown on the io pin */
ESP_RETURN_ON_ERROR(rtc_gpio_pulldown_dis(io_num), RTCI2C_TAG, "RTC GPIO pulldown disable failed for %d", io_num);
/* Enable pullup based on pullup_en flag */
Expand Down Expand Up @@ -479,6 +479,15 @@ esp_err_t ulp_riscv_i2c_master_init(const ulp_riscv_i2c_cfg_t *cfg)
/* Configure RTC I2C GPIOs */
ESP_RETURN_ON_ERROR(i2c_set_pin(cfg), RTCI2C_TAG, "Failed to configure RTC I2C GPIOs");

/* Enable internal open-drain mode for SDA and SCL lines */
#if CONFIG_IDF_TARGET_ESP32S2
i2c_dev->ctrl.sda_force_out = 0;
i2c_dev->ctrl.scl_force_out = 0;
#elif CONFIG_IDF_TARGET_ESP32S3
i2c_dev->i2c_ctrl.i2c_sda_force_out = 0;
i2c_dev->i2c_ctrl.i2c_scl_force_out = 0;
#endif // CONFIG_IDF_TARGET_ESP32S2

#if CONFIG_IDF_TARGET_ESP32S2
/* Configure the RTC I2C controller in master mode */
i2c_dev->ctrl.ms_mode = 1;
Expand Down

0 comments on commit 2c0d846

Please sign in to comment.