HPM SDK
HPMicro Software Development Kit
hpm_acmp_soc_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 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 
12 static inline void acmp_enable_bandgap(void)
13 {
14  uint32_t clk_div_temp;
15 
16  clk_div_temp = ADC16_CONV_CFG1_CLOCK_DIVIDER_GET(HPM_ADC3->CONV_CFG1);
17 
18  /* Set input clock divider temporarily */
19  HPM_ADC3->CONV_CFG1 = (HPM_ADC3->CONV_CFG1 & ~ADC16_CONV_CFG1_CLOCK_DIVIDER_MASK)
21 
22  /* Enable ADC config clock */
24 
25  /* Enable bandgap_en */
27 
28  /* Recover input clock divider */
29  HPM_ADC3->CONV_CFG1 = (HPM_ADC3->CONV_CFG1 & ~ADC16_CONV_CFG1_CLOCK_DIVIDER_MASK)
30  | ADC16_CONV_CFG1_CLOCK_DIVIDER_SET(clk_div_temp);
31 
32  /* Disable ADC config clock */
34 }
35 
36 #endif /* HPM_ACMP_SOC_DRV_H */
#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:219
static void acmp_enable_bandgap(void)
Definition: hpm_acmp_soc_drv.h:12