Skip to content

Commit f071412

Browse files
eren-terziogluxiaoxiang781216
authored andcommitted
arch/risc-v: Bugfix I2C Slave build error for esp32[-c3|-c6|-h2]
Fix build error for risc-v based Espressif devices Signed-off-by: Eren Terzioglu <[email protected]>
1 parent 8995226 commit f071412

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

arch/risc-v/src/common/espressif/esp_i2c_slave.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@
8080
#define I2C_SLAVE_POLL_RATE 10
8181
#endif
8282

83+
#if !SOC_RCC_IS_INDEPENDENT
84+
# define I2C_RCC_ATOMIC() PERIPH_RCC_ATOMIC()
85+
#else
86+
# define I2C_RCC_ATOMIC()
87+
#endif
88+
8389
/****************************************************************************
8490
* Private Types
8591
****************************************************************************/
@@ -540,7 +546,11 @@ static void esp_i2c_slave_init(struct esp_i2c_priv_s *priv)
540546

541547
/* Enable I2C hardware */
542548

543-
periph_module_enable(PERIPH_I2C0_MODULE);
549+
I2C_RCC_ATOMIC()
550+
{
551+
i2c_ll_enable_bus_clock(priv->id, true);
552+
i2c_ll_reset_register(priv->id);
553+
}
544554

545555
i2c_hal_init(priv->ctx, priv->id);
546556

@@ -583,7 +593,10 @@ static void esp_i2c_slave_deinit(struct esp_i2c_priv_s *priv)
583593
const struct esp_i2c_config_s *config = priv->config;
584594

585595
i2c_hal_deinit(priv->ctx);
586-
periph_module_disable(PERIPH_I2C0_MODULE);
596+
I2C_RCC_ATOMIC()
597+
{
598+
i2c_ll_enable_bus_clock(priv->id, false);
599+
}
587600
}
588601

589602
/****************************************************************************

0 commit comments

Comments
 (0)