MG32L003 Standard Peripherals Firmware Library
mg32l003_vcmp.h
Go to the documentation of this file.
1 
10 /* Define to prevent recursive inclusion -------------------------------------*/
11 #ifndef __MG32L003_VCMP_H
12 #define __MG32L003_VCMP_H
13 
14 #ifdef __cplusplus
15  extern "C" {
16 #endif
17 
18 /* Includes ------------------------------------------------------------------*/
19 #include "mg32l003.h"
20 
25 /* Exported types ------------------------------------------------------------*/
26 
30 typedef struct
31 {
32  uint32_t VcapDiv;
33  uint32_t NegPinSel;
34  uint32_t PosPinSel;
35  uint32_t Filter_Enable;
36  uint32_t Filter_Clk;
37  uint32_t Fliter_Num;
39 
40 /* Exported constants --------------------------------------------------------*/
41 
49 #define VCMP_VCAPDIV_ENABLE VCMP_CR0_VCAPDIV_EN
50 #define VCMP_VCAPDIV_DISABLE (0x0U)
52 #define VCMP_INT_ENABLE VCMP_CR1_INT_EN
53 #define VCMP_INT_DISABLE (0x0U)
55 #define VCMP_ENABLE VCMP_CR1_VCEN
56 #define VCMP_DISABLE (0x0U)
64 #define VCMP_1P4_VCAPDIV (0x00U)
65 #define VCMP_2P4_VCAPDIV (0x01U)
66 #define VCMP_3P4_VCAPDIV (0x02U)
67 #define VCMP_4P4_VCAPDIV (0x03U)
69 #define IS_VCMP_VCAPDIV(VCMP_VCAPDIV) (((VCMP_VCAPDIV) == VCMP_1P4_VCAPDIV) || ((VCMP_VCAPDIV) == VCMP_2P4_VCAPDIV) || \
70  ((VCMP_VCAPDIV) == VCMP_3P4_VCAPDIV) || ((VCMP_VCAPDIV) == VCMP_4P4_VCAPDIV))
71 
78 #define VCMP_INPUT_0 (0x00U)
79 #define VCMP_INPUT_1 (0x01U)
80 #define VCMP_INPUT_2 (0x02U)
81 #define VCMP_INPUT_VCAPDIV (0x03U)
82 
83 #define IS_VCMP_INPUT(VCMP_INPUT) (((VCMP_INPUT) == VCMP_INPUT_0) || ((VCMP_INPUT) == VCMP_INPUT_1) || \
84  ((VCMP_INPUT) == VCMP_INPUT_2) || ((VCMP_INPUT) == VCMP_INPUT_VCAPDIV))
85 
92 #define VCMP_FILTER_ENABLE VCMP_CR1_FLTEN
93 #define VCMP_FILTER_DISABLE (0x0U)
95 #define IS_VCMP_FILTER_ENABLE(FILTER) (((FILTER) == VCMP_FILTER_ENABLE) || ((FILTER) == VCMP_FILTER_DISABLE))
96 #define IS_VCMP_FILTER_NUM(FILTER_NUM) (((FILTER_NUM) >= 0U) && ((FILTER_NUM) <= 0xFFFFU))
97 
104 #define VCMP_HIGH_INT VCMP_CR1_HIGHINTEN
105 #define VCMP_RISE_INT VCMP_CR1_RISEINTEN
106 #define VCMP_FALL_INT VCMP_CR1_FALLINTEN
107 #define VCMP_INT_MASK (VCMP_HIGH_INT | VCMP_RISE_INT | VCMP_FALL_INT)
108 
109 #define IS_VCMP_INT(VCMP_INT) (((VCMP_INT) == VCMP_HIGH_INT) || ((VCMP_INT) == VCMP_RISE_INT) || \
110  ((VCMP_INT) == VCMP_FALL_INT))
111 
118 #define VCMP_FILTER_CLK_NONE (0x00U)
119 #define VCMP_FILTER_CLK_PCLK (0x01U << VCMP_CR1_VCMP_FLTCLK_SEL_Pos)
120 #define VCMP_FILTER_CLK_LSI (0x02U << VCMP_CR1_VCMP_FLTCLK_SEL_Pos)
122 #define IS_VCMP_FILTER_CLOCK(FILTER_CLOCK) (((FILTER_CLOCK) == VCMP_FILTER_CLK_NONE) || \
123  ((FILTER_CLOCK) == VCMP_FILTER_CLK_PCLK) || \
124  ((FILTER_CLOCK) == VCMP_FILTER_CLK_LSI))
125 
132 #define VCMP_OUTCFG_INV_PAD (0x01 << VCMP_OUTCFG_INV_PAD_Pos)
133 #define VCMP_OUTCFG_TIM1_BKE (0x01 << VCMP_OUTCFG_TIM1BKE_Pos)
134 #define VCMP_OUTCFG_TIM1CH4_GATE (0x01 << VCMP_OUTCFG_TIM1CH4_EN_Pos)
135 #define VCMP_OUTCFG_INV_TIM1CH4_GATE (0x01 << VCMP_OUTCFG_INV_TIM1CH4_Pos)
136 #define VCMP_OUTCFG_TIM1CH3_GATE (0x01 << VCMP_OUTCFG_TIM1CH3_EN_Pos)
137 #define VCMP_OUTCFG_INV_TIM1CH3_GATE (0x01 << VCMP_OUTCFG_INV_TIM1CH3_Pos)
138 #define VCMP_OUTCFG_TIM1CH2_GATE (0x01 << VCMP_OUTCFG_TIM1CH2_EN_Pos)
139 #define VCMP_OUTCFG_INV_TIM1CH2_GATE (0x01 << VCMP_OUTCFG_INV_TIM1CH2_Pos)
140 #define VCMP_OUTCFG_TIM1CH1_GATE (0x01 << VCMP_OUTCFG_TIM1CH1_EN_Pos)
141 #define VCMP_OUTCFG_INV_TIM1CH1_GATE (0x01 << VCMP_OUTCFG_INV_TIM1CH1_Pos)
142 #define VCMP_OUTCFG_PCA_EXTCLK_EN (0x01 << VCMP_OUTCFG_PCAECI_EN_Pos)
143 #define VCMP_OUTCFG_PCA_CAP0_EN (0x01 << VCMP_OUTCFG_PCACAP0_EN_Pos)
144 #define VCMP_OUTCFG_INV_PCA (0x01 << VCMP_OUTCFG_INV_PCA_Pos)
145 #define VCMP_OUTCFG_LPTIM_EXTCLK_EN (0x01 << VCMP_OUTCFG_LPTIMEXT_EN_Pos)
146 #define VCMP_OUTCFG_LPTIM_GATE (0x01 << VCMP_OUTCFG_LPTIM_EN_Pos)
147 #define VCMP_OUTCFG_TIM11_GATE (0x01 << VCMP_OUTCFG_TIM11_EN_Pos)
148 #define VCMP_OUTCFG_TIM10_GATE (0x01 << VCMP_OUTCFG_TIM10_EN_Pos)
149 #define VCMP_OUTCFG_INV_LPTIM_TIM10_11 (0x01 << VCMP_OUTCFG_INV_TIMX_Pos)
150 
151 #define VCMP_OUTCFG_MSK (0x7FFFFU)
152 #define IS_VCMP_OUTCFG(OUTCFG) (((OUTCFG) & VCMP_OUTCFG_MSK) != 0x0000U)
153 
161 /* Exported macros -----------------------------------------------------------*/
162 /* Exported functions --------------------------------------------------------*/
163 
164 void VCMP_DeInit(void);
165 void VCMP_Init(VCMP_InitTypeDef *InitStruct);
166 void VCMP_ITConfig(uint32_t Config, FunctionalState NewState);
167 void VCMP_ITCmd(FunctionalState NewState);
168 void VCMP_OutputConfig(uint32_t Config, FunctionalState NewState);
169 FlagStatus VCMP_GetFlagStatus(void);
170 ITStatus VCMP_GetITStatus(void);
171 void VCMP_ClearITPendingBit(void);
172 void VCMP_ClearFlag(void);
173 FlagStatus VCMP_GetOutputStatus(void);
174 void VCMP_Cmd(FunctionalState NewState);
175 
184 #ifdef __cplusplus
185 }
186 #endif
187 
188 #endif /* __MG32L003_VCMP_H */
void VCMP_ITConfig(uint32_t Config, FunctionalState NewState)
Enables or disables the specified VCMP interrupts.
Definition: mg32l003_vcmp.c:93
uint32_t PosPinSel
Definition: mg32l003_vcmp.h:34
void VCMP_Cmd(FunctionalState NewState)
Enables or disables VCMP peripheral(write access to VCMP_CR1 registers).
Definition: mg32l003_vcmp.c:262
FlagStatus VCMP_GetOutputStatus(void)
Checks VCMP output is set or reset.
Definition: mg32l003_vcmp.c:240
uint32_t Filter_Clk
Definition: mg32l003_vcmp.h:36
uint32_t NegPinSel
Definition: mg32l003_vcmp.h:33
void VCMP_ClearITPendingBit(void)
Clears VCMP interrupt.
Definition: mg32l003_vcmp.c:230
uint32_t VcapDiv
Definition: mg32l003_vcmp.h:32
void VCMP_ITCmd(FunctionalState NewState)
Enables or disables VCMP interrupt.
Definition: mg32l003_vcmp.c:115
void VCMP_DeInit(void)
Deinitializes the VCMP peripheral.
Definition: mg32l003_vcmp.c:38
void VCMP_Init(VCMP_InitTypeDef *InitStruct)
Initializes the VCMP according to the specified parameters in the VCMP_HandleTypeDef.
Definition: mg32l003_vcmp.c:51
uint32_t Fliter_Num
Definition: mg32l003_vcmp.h:37
void VCMP_OutputConfig(uint32_t Config, FunctionalState NewState)
Enables or disables the specified VCMP outputs.
Definition: mg32l003_vcmp.c:156
uint32_t Filter_Enable
Definition: mg32l003_vcmp.h:35
VCMP Init structure definition.
Definition: mg32l003_vcmp.h:30
FlagStatus VCMP_GetFlagStatus(void)
Checks whether VCMP interrupt flag is set or reset.
Definition: mg32l003_vcmp.c:176
void VCMP_ClearFlag(void)
Clears VCMP interrupt flag.
Definition: mg32l003_vcmp.c:220
ITStatus VCMP_GetITStatus(void)
Checks whether VCMP interrupt is set or reset.
Definition: mg32l003_vcmp.c:198