mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-10 04:43:33 +00:00
Merge branch 'refactor/regi2c_mst_clock_enable' into 'master'
refactor(regi2c): analog i2c mst clock should be enabled/disabled per usage Closes IDF-10492 and IDF-10693 See merge request espressif/esp-idf!32682
This commit is contained in:
@@ -135,7 +135,7 @@ static inline void adc_ll_digi_set_fsm_time(uint32_t rst_wait, uint32_t start_wa
|
||||
*/
|
||||
static inline void adc_ll_set_sample_cycle(uint32_t sample_cycle)
|
||||
{
|
||||
/* Peripheral reg i2c has powered up in rtc_init, write directly */
|
||||
/* Analog i2c master clock needs to be enabled for regi2c operations (done inside REGI2C_WRITE_MASK) */
|
||||
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_SAMPLE_CYCLE_ADDR, sample_cycle);
|
||||
}
|
||||
|
||||
|
@@ -347,7 +347,7 @@ static inline __attribute__((always_inline)) uint32_t clk_ll_cpll_get_freq_mhz(u
|
||||
unsigned chip_version = efuse_hal_chip_revision();
|
||||
if (!ESP_CHIP_REV_ABOVE(chip_version, 1)) {
|
||||
return xtal_freq_mhz * (div + 4) / (ref_div + 1);
|
||||
} else
|
||||
}
|
||||
return xtal_freq_mhz * div / (ref_div + 1);
|
||||
}
|
||||
|
||||
|
@@ -21,25 +21,33 @@ extern "C" {
|
||||
/**
|
||||
* @brief Enable analog I2C master clock
|
||||
*/
|
||||
static inline __attribute__((always_inline)) void regi2c_ctrl_ll_master_enable_clock(bool en)
|
||||
static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_enable_clock(bool en)
|
||||
{
|
||||
LPPERI.clk_en.ck_en_lp_i2cmst = en;
|
||||
}
|
||||
|
||||
// LPPERI.clk_en is a shared register, so this function must be used in an atomic way
|
||||
#define regi2c_ctrl_ll_master_enable_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; regi2c_ctrl_ll_master_enable_clock(__VA_ARGS__)
|
||||
#define regi2c_ctrl_ll_master_enable_clock(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _regi2c_ctrl_ll_master_enable_clock(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Check whether analog I2C master clock is enabled
|
||||
*/
|
||||
static inline __attribute__((always_inline)) bool regi2c_ctrl_ll_master_is_clock_enabled(void)
|
||||
{
|
||||
return LPPERI.clk_en.ck_en_lp_i2cmst;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reset analog I2C master
|
||||
*/
|
||||
static inline __attribute__((always_inline)) void regi2c_ctrl_ll_master_reset(void)
|
||||
static inline __attribute__((always_inline)) void _regi2c_ctrl_ll_master_reset(void)
|
||||
{
|
||||
LPPERI.reset_en.rst_en_lp_i2cmst = 1;
|
||||
LPPERI.reset_en.rst_en_lp_i2cmst = 0;
|
||||
}
|
||||
|
||||
// LPPERI.reset_en is a shared register, so this function must be used in an atomic way
|
||||
#define regi2c_ctrl_ll_master_reset(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; regi2c_ctrl_ll_master_reset(__VA_ARGS__)
|
||||
#define regi2c_ctrl_ll_master_reset(...) (void)__DECLARE_RCC_RC_ATOMIC_ENV; _regi2c_ctrl_ll_master_reset(__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @brief Configure analog I2C master clock
|
||||
|
Reference in New Issue
Block a user