Skip to content

Commit

Permalink
ulp risc-v rtc i2c: Fix a bug where RTC I2C failed to initialize afte…
Browse files Browse the repository at this point in the history
…r esp_restart()

This commit fixes a bug wherein the RTC I2C peripheral got stuck after
the main CPU performs a soft reset by using esp_restart(). This is
because the RTC domain config registers for the RTC I2C domain are not
cleared after the soft restart and hence need to be cleared manually
while initializing the RTC I2C peripheral again.

Closes #10468
  • Loading branch information
sudeep-mohanty committed Jan 2, 2023
1 parent 4c98bee commit 4a41039
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/ulp/ulp_riscv/ulp_riscv_i2c.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -398,6 +398,10 @@ void ulp_riscv_i2c_master_write_to_device(uint8_t *data_wr, size_t size)

esp_err_t ulp_riscv_i2c_master_init(const ulp_riscv_i2c_cfg_t *cfg)
{
/* Clear any stale config registers */
WRITE_PERI_REG(RTC_I2C_CTRL_REG, 0);
WRITE_PERI_REG(SENS_SAR_I2C_CTRL_REG, 0);

/* Reset RTC I2C */
#if CONFIG_IDF_TARGET_ESP32S2
i2c_dev->ctrl.i2c_reset = 1;
Expand Down

0 comments on commit 4a41039

Please sign in to comment.