139
139
#define I2C_SLAVE_POLL_RATE 10
140
140
#endif
141
141
142
+ #if !SOC_RCC_IS_INDEPENDENT
143
+ # define I2C_RCC_ATOMIC () PERIPH_RCC_ATOMIC()
144
+ #else
145
+ # define I2C_RCC_ATOMIC ()
146
+ #endif
147
+
142
148
/****************************************************************************
143
149
* Private Types
144
150
****************************************************************************/
@@ -599,7 +605,11 @@ static void esp_i2c_slave_init(struct esp_i2c_priv_s *priv)
599
605
600
606
/* Enable I2C hardware */
601
607
602
- periph_module_enable (i2c_periph_signal [priv -> id ].module );
608
+ I2C_RCC_ATOMIC ()
609
+ {
610
+ i2c_ll_enable_bus_clock (priv -> id , true);
611
+ i2c_ll_reset_register (priv -> id );
612
+ }
603
613
604
614
i2c_hal_init (priv -> ctx , priv -> id );
605
615
@@ -610,7 +620,7 @@ static void esp_i2c_slave_init(struct esp_i2c_priv_s *priv)
610
620
/* Initialize I2C Slave */
611
621
612
622
i2c_hal_slave_init (priv -> ctx );
613
- i2c_ll_slave_tx_auto_start_en (priv -> ctx -> dev , true);
623
+ i2c_ll_slave_enable_auto_start (priv -> ctx -> dev , true);
614
624
i2c_ll_set_source_clk (priv -> ctx -> dev , I2C_CLK_SRC_DEFAULT );
615
625
i2c_ll_set_slave_addr (priv -> ctx -> dev , priv -> addr , false);
616
626
i2c_ll_set_rxfifo_full_thr (priv -> ctx -> dev , I2C_FIFO_FULL_THRESH_VAL );
@@ -642,7 +652,10 @@ static void esp_i2c_slave_deinit(struct esp_i2c_priv_s *priv)
642
652
const struct esp_i2c_config_s * config = priv -> config ;
643
653
644
654
i2c_hal_deinit (priv -> ctx );
645
- periph_module_disable (i2c_periph_signal [priv -> id ].module );
655
+ I2C_RCC_ATOMIC ()
656
+ {
657
+ i2c_ll_enable_bus_clock (priv -> id , false);
658
+ }
646
659
}
647
660
648
661
/****************************************************************************
0 commit comments