HPM SDK
HPMicro Software Development Kit
hpm_acmp_soc_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023-2024 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 #ifndef HPM_ACMP_SOC_DRV_H
8 #define HPM_ACMP_SOC_DRV_H
9 
10 #include "hpm_soc.h"
11 #include "hpm_clock_drv.h"
12 
13 static inline void acmp_enable_bandgap(void)
14 {
15  uint32_t clk_div_temp;
16 
18 
20 
21  clk_div_temp = ADC16_CONV_CFG1_CLOCK_DIVIDER_GET(HPM_ADC3->CONV_CFG1);
22 
23  /* Set input clock divider temporarily */
24  HPM_ADC3->CONV_CFG1 = (HPM_ADC3->CONV_CFG1 & ~ADC16_CONV_CFG1_CLOCK_DIVIDER_MASK)
26 
27  /* Enable ADC config clock */
29 
30  /* Enable bandgap_en */
32 
33  /* Recover input clock divider */
34  HPM_ADC3->CONV_CFG1 = (HPM_ADC3->CONV_CFG1 & ~ADC16_CONV_CFG1_CLOCK_DIVIDER_MASK)
35  | ADC16_CONV_CFG1_CLOCK_DIVIDER_SET(clk_div_temp);
36 
37  /* Disable ADC config clock */
39 }
40 
41 #endif /* HPM_ACMP_SOC_DRV_H */
@ clk_adc_src_ahb0
Definition: hpm_clock_drv.h:67
#define ADC16_CONV_CFG1_CLOCK_DIVIDER_GET(x)
Definition: hpm_adc16_regs.h:513
#define ADC16_ANA_CTRL0_ADC_CLK_ON_MASK
Definition: hpm_adc16_regs.h:801
#define ADC16_ADC16_CONFIG0_BANDGAP_EN_MASK
Definition: hpm_adc16_regs.h:853
#define ADC16_CONV_CFG1_CLOCK_DIVIDER_MASK
Definition: hpm_adc16_regs.h:510
#define ADC16_CONV_CFG1_CLOCK_DIVIDER_SET(x)
Definition: hpm_adc16_regs.h:512
#define HPM_ADC3
Definition: hpm_soc.h:91
@ clock_adc3
Definition: hpm_clock_drv.h:212
void clock_add_to_group(clock_name_t clock_name, uint32_t group)
Add IP to specified group.
Definition: hpm_clock_drv.c:438
hpm_stat_t clock_set_adc_source(clock_name_t clock_name, clk_src_t src)
Set ADC clock source.
Definition: hpm_clock_drv.c:324
static void acmp_enable_bandgap(void)
Definition: hpm_acmp_soc_drv.h:13