Skip to content

Commit

Permalink
feat(adc): add ADC func clock enable function on C5,C6,H2
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce297 committed Jul 13, 2024
1 parent 65820c0 commit 2f49a2e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/esp_hw_support/adc_share_hw_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ void adc_apb_periph_claim(void)
if (s_adc_digi_ctrlr_cnt == 1) {
ADC_BUS_CLK_ATOMIC() {
adc_ll_enable_bus_clock(true);
#if SOC_RCC_IS_INDEPENDENT
adc_ll_enable_func_clock(true);
#endif
adc_ll_reset_register();
}
}
Expand All @@ -221,6 +224,9 @@ void adc_apb_periph_free(void)
if (s_adc_digi_ctrlr_cnt == 0) {
ADC_BUS_CLK_ATOMIC() {
adc_ll_enable_bus_clock(false);
#if SOC_RCC_IS_INDEPENDENT
adc_ll_enable_func_clock(false);
#endif
}
} else if (s_adc_digi_ctrlr_cnt < 0) {
portEXIT_CRITICAL(&s_spinlock);
Expand Down
11 changes: 11 additions & 0 deletions components/hal/esp32c5/include/hal/adc_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,17 @@ static inline void adc_ll_enable_bus_clock(bool enable)
PCR.saradc_conf.saradc_reg_clk_en = enable;
}

#if SOC_RCC_IS_INDEPENDENT
/**
* @brief Enable the ADC function clock
* @param enable true to enable, false to disable
*/
static inline void adc_ll_enable_func_clock(bool enable)
{
PCR.saradc_clkm_conf.saradc_clkm_en = enable;
}
#endif

/**
* @brief Reset ADC module
*/
Expand Down
11 changes: 11 additions & 0 deletions components/hal/esp32c6/include/hal/adc_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,17 @@ static inline void adc_ll_enable_bus_clock(bool enable)
PCR.saradc_conf.saradc_reg_clk_en = enable;
}

#if SOC_RCC_IS_INDEPENDENT
/**
* @brief Enable the ADC function clock
* @param enable true to enable, false to disable
*/
static inline void adc_ll_enable_func_clock(bool enable)
{
PCR.saradc_clkm_conf.saradc_clkm_en = enable;
}
#endif

/**
* @brief Reset ADC module
*/
Expand Down
11 changes: 11 additions & 0 deletions components/hal/esp32h2/include/hal/adc_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,17 @@ static inline void adc_ll_enable_bus_clock(bool enable)
PCR.saradc_conf.saradc_reg_clk_en = enable;
}

#if SOC_RCC_IS_INDEPENDENT
/**
* @brief Enable the ADC function clock
* @param enable true to enable, false to disable
*/
static inline void adc_ll_enable_func_clock(bool enable)
{
PCR.saradc_clkm_conf.saradc_clkm_en = enable;
}
#endif

/**
* @brief Reset ADC module
*/
Expand Down

0 comments on commit 2f49a2e

Please sign in to comment.