M480 BSP  V3.05.001
The Board Support Package for M480 Series
acmp.h
Go to the documentation of this file.
1 /**************************************************************************/
9 #ifndef __ACMP_H__
10 #define __ACMP_H__
11 
12 
13 #ifdef __cplusplus
14 extern "C"
15 {
16 #endif
17 
18 
35 /*---------------------------------------------------------------------------------------------------------*/
36 /* ACMP_CTL constant definitions */
37 /*---------------------------------------------------------------------------------------------------------*/
38 #define ACMP_CTL_FILTSEL_OFF (0UL << ACMP_CTL_FILTSEL_Pos)
39 #define ACMP_CTL_FILTSEL_1PCLK (1UL << ACMP_CTL_FILTSEL_Pos)
40 #define ACMP_CTL_FILTSEL_2PCLK (2UL << ACMP_CTL_FILTSEL_Pos)
41 #define ACMP_CTL_FILTSEL_4PCLK (3UL << ACMP_CTL_FILTSEL_Pos)
42 #define ACMP_CTL_FILTSEL_8PCLK (4UL << ACMP_CTL_FILTSEL_Pos)
43 #define ACMP_CTL_FILTSEL_16PCLK (5UL << ACMP_CTL_FILTSEL_Pos)
44 #define ACMP_CTL_FILTSEL_32PCLK (6UL << ACMP_CTL_FILTSEL_Pos)
45 #define ACMP_CTL_FILTSEL_64PCLK (7UL << ACMP_CTL_FILTSEL_Pos)
46 #define ACMP_CTL_INTPOL_RF (0UL << ACMP_CTL_INTPOL_Pos)
47 #define ACMP_CTL_INTPOL_R (1UL << ACMP_CTL_INTPOL_Pos)
48 #define ACMP_CTL_INTPOL_F (2UL << ACMP_CTL_INTPOL_Pos)
49 #define ACMP_CTL_POSSEL_P0 (0UL << ACMP_CTL_POSSEL_Pos)
50 #define ACMP_CTL_POSSEL_P1 (1UL << ACMP_CTL_POSSEL_Pos)
51 #define ACMP_CTL_POSSEL_P2 (2UL << ACMP_CTL_POSSEL_Pos)
52 #define ACMP_CTL_POSSEL_P3 (3UL << ACMP_CTL_POSSEL_Pos)
53 #define ACMP_CTL_NEGSEL_PIN (0UL << ACMP_CTL_NEGSEL_Pos)
54 #define ACMP_CTL_NEGSEL_CRV (1UL << ACMP_CTL_NEGSEL_Pos)
55 #define ACMP_CTL_NEGSEL_VBG (2UL << ACMP_CTL_NEGSEL_Pos)
56 #define ACMP_CTL_NEGSEL_DAC (3UL << ACMP_CTL_NEGSEL_Pos)
57 #define ACMP_CTL_HYSTERESIS_30MV (3UL << ACMP_CTL_HYSSEL_Pos)
58 #define ACMP_CTL_HYSTERESIS_20MV (2UL << ACMP_CTL_HYSSEL_Pos)
59 #define ACMP_CTL_HYSTERESIS_10MV (1UL << ACMP_CTL_HYSSEL_Pos)
60 #define ACMP_CTL_HYSTERESIS_DISABLE (0UL << ACMP_CTL_HYSSEL_Pos)
62 /*---------------------------------------------------------------------------------------------------------*/
63 /* ACMP_VREF constant definitions */
64 /*---------------------------------------------------------------------------------------------------------*/
65 #define ACMP_VREF_CRVSSEL_VDDA (0UL << ACMP_VREF_CRVSSEL_Pos)
66 #define ACMP_VREF_CRVSSEL_INTVREF (1UL << ACMP_VREF_CRVSSEL_Pos)
69  /* end of group ACMP_EXPORTED_CONSTANTS */
70 
71 
76 /*---------------------------------------------------------------------------------------------------------*/
77 /* Define Macros and functions */
78 /*---------------------------------------------------------------------------------------------------------*/
79 
80 
89 #define ACMP_ENABLE_OUTPUT_INVERSE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_ACMPOINV_Msk)
90 
99 #define ACMP_DISABLE_OUTPUT_INVERSE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_ACMPOINV_Msk)
100 
114 #define ACMP_SET_NEG_SRC(acmp, u32ChNum, u32Src) ((acmp)->CTL[(u32ChNum)] = ((acmp)->CTL[(u32ChNum)] & ~ACMP_CTL_NEGSEL_Msk) | (u32Src))
115 
123 #define ACMP_ENABLE_HYSTERESIS(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_HYSTERESIS_30MV)
124 
133 #define ACMP_DISABLE_HYSTERESIS(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_HYSSEL_Msk)
134 
147 #define ACMP_CONFIG_HYSTERESIS(acmp, u32ChNum, u32HysSel) ((acmp)->CTL[(u32ChNum)] = ((acmp)->CTL[(u32ChNum)] & ~ACMP_CTL_HYSSEL_Msk) | (u32HysSel))
148 
158 #define ACMP_ENABLE_INT(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_ACMPIE_Msk)
159 
168 #define ACMP_DISABLE_INT(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_ACMPIE_Msk)
169 
178 #define ACMP_ENABLE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_ACMPEN_Msk)
179 
188 #define ACMP_DISABLE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_ACMPEN_Msk)
189 
198 #define ACMP_GET_OUTPUT(acmp, u32ChNum) (((acmp)->STATUS & (ACMP_STATUS_ACMPO0_Msk<<((u32ChNum))))?1:0)
199 
208 #define ACMP_GET_INT_FLAG(acmp, u32ChNum) (((acmp)->STATUS & (ACMP_STATUS_ACMPIF0_Msk<<((u32ChNum))))?1:0)
209 
218 #define ACMP_CLR_INT_FLAG(acmp, u32ChNum) ((acmp)->STATUS = (ACMP_STATUS_ACMPIF0_Msk<<((u32ChNum))))
219 
228 #define ACMP_CLR_WAKEUP_INT_FLAG(acmp, u32ChNum) ((acmp)->STATUS = (ACMP_STATUS_WKIF0_Msk<<((u32ChNum))))
229 
238 #define ACMP_ENABLE_WAKEUP(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_WKEN_Msk)
239 
248 #define ACMP_DISABLE_WAKEUP(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_WKEN_Msk)
249 
263 #define ACMP_SELECT_P(acmp, u32ChNum, u32Pin) ((acmp)->CTL[(u32ChNum)] = ((acmp)->CTL[(u32ChNum)] & ~ACMP_CTL_POSSEL_Msk) | (u32Pin))
264 
273 #define ACMP_ENABLE_FILTER(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_OUTSEL_Msk)
274 
283 #define ACMP_DISABLE_FILTER(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_OUTSEL_Msk)
284 
302 #define ACMP_SET_FILTER(acmp, u32ChNum, u32Cnt) ((acmp)->CTL[(u32ChNum)] = ((acmp)->CTL[(u32ChNum)] & ~ACMP_CTL_FILTSEL_Msk) | (u32Cnt))
303 
315 #define ACMP_CRV_SEL(acmp, u32Level) ((acmp)->VREF = ((acmp)->VREF & ~ACMP_VREF_CRVCTL_Msk) | ((u32Level)<<ACMP_VREF_CRVCTL_Pos))
316 
327 #define ACMP_SELECT_CRV_SRC(acmp, u32Src) ((acmp)->VREF = ((acmp)->VREF & ~ACMP_VREF_CRVSSEL_Msk) | (u32Src))
328 
341 #define ACMP_SELECT_INT_COND(acmp, u32ChNum, u32Cond) ((acmp)->CTL[(u32ChNum)] = ((acmp)->CTL[(u32ChNum)] & ~ACMP_CTL_INTPOL_Msk) | (u32Cond))
342 
354 #define ACMP_ENABLE_WINDOW_LATCH(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_WLATEN_Msk)
355 
364 #define ACMP_DISABLE_WINDOW_LATCH(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_WLATEN_Msk)
365 
381 #define ACMP_ENABLE_WINDOW_COMPARE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] |= ACMP_CTL_WCMPSEL_Msk)
382 
391 #define ACMP_DISABLE_WINDOW_COMPARE(acmp, u32ChNum) ((acmp)->CTL[(u32ChNum)] &= ~ACMP_CTL_WCMPSEL_Msk)
392 
393 
394 
395 
396 /* Function prototype declaration */
397 void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysSel);
398 void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum);
399 
400 
401  /* end of group ACMP_EXPORTED_FUNCTIONS */
403  /* end of group ACMP_Driver */
405  /* end of group Standard_Driver */
407 
408 #ifdef __cplusplus
409 }
410 #endif
411 
412 
413 #endif /* __ACMP_H__ */
414 
415 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysSel)
Configure the specified ACMP module.
Definition: acmp.c:46
void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum)
Close analog comparator.
Definition: acmp.c:61