| NUC472_NUC442_BSP V3.03.003 The Board Support Package for NUC472/NUC442

acmp.h
Go to the documentation of this file.
1/**************************************************************************/
12#ifndef __ACMP_H__
13#define __ACMP_H__
14
15#ifdef __cplusplus
16 extern "C"
17{
18#endif
19
20
33/*---------------------------------------------------------------------------------------------------------*/
34/* ACMP_CR constant definitions */
35/*---------------------------------------------------------------------------------------------------------*/
36#define ACMP_VNEG_PIN (0xFFUL)
37#define ACMP_VNEG_BANDGAP (0x00UL)
38#define ACMP_VNEG_4_OVER_24_VDD (0x80UL)
39#define ACMP_VNEG_5_OVER_24_VDD (0x81UL)
40#define ACMP_VNEG_6_OVER_24_VDD (0x82UL)
41#define ACMP_VNEG_7_OVER_24_VDD (0x83UL)
42#define ACMP_VNEG_8_OVER_24_VDD (0x84UL)
43#define ACMP_VNEG_9_OVER_24_VDD (0x85UL)
44#define ACMP_VNEG_10_OVER_24_VDD (0x86UL)
45#define ACMP_VNEG_11_OVER_24_VDD (0x87UL)
46#define ACMP_VNEG_12_OVER_24_VDD (0x88UL)
47#define ACMP_VNEG_13_OVER_24_VDD (0x89UL)
48#define ACMP_VNEG_14_OVER_24_VDD (0x8AUL)
49#define ACMP_VNEG_15_OVER_24_VDD (0x8BUL)
50#define ACMP_VNEG_16_OVER_24_VDD (0x8CUL)
51#define ACMP_VNEG_17_OVER_24_VDD (0x8DUL)
52#define ACMP_VNEG_18_OVER_24_VDD (0x8EUL)
53#define ACMP_VNEG_19_OVER_24_VDD (0x8FUL)
54#define ACMP_VNEG_4_OVER_24_IREF (0xC0UL)
55#define ACMP_VNEG_5_OVER_24_IREF (0xC1UL)
56#define ACMP_VNEG_6_OVER_24_IREF (0xC2UL)
57#define ACMP_VNEG_7_OVER_24_IREF (0xC3UL)
58#define ACMP_VNEG_8_OVER_24_IREF (0xC4UL)
59#define ACMP_VNEG_9_OVER_24_IREF (0xC5UL)
60#define ACMP_VNEG_10_OVER_24_IREF (0xC6UL)
61#define ACMP_VNEG_11_OVER_24_IREF (0xC7UL)
62#define ACMP_VNEG_12_OVER_24_IREF (0xC8UL)
63#define ACMP_VNEG_13_OVER_24_IREF (0xC9UL)
64#define ACMP_VNEG_14_OVER_24_IREF (0xCAUL)
65#define ACMP_VNEG_15_OVER_24_IREF (0xCBUL)
66#define ACMP_VNEG_16_OVER_24_IREF (0xCCUL)
67#define ACMP_VNEG_17_OVER_24_IREF (0xCDUL)
68#define ACMP_VNEG_18_OVER_24_IREF (0xCEUL)
69#define ACMP_VNEG_19_OVER_24_IREF (0xCFUL)
70#define ACMP_HYSTERESIS_ENABLE (1UL << ACMP_CTL_HYSEN_Pos)
71#define ACMP_HYSTERESIS_DISABLE (0UL)
72#define ACMP_CH0_POSPIN_P0 (0UL)
73#define ACMP_CH0_POSPIN_P1 (1UL << ACMP_CTL_POSSEL_Pos)
74#define ACMP_CH0_POSPIN_P2 (2UL << ACMP_CTL_POSSEL_Pos)
75#define ACMP_CH0_POSPIN_P3 (3UL << ACMP_CTL_POSSEL_Pos)
76#define ACMP_CH0_POS_OPA0 (4UL << ACMP_CTL_POSSEL_Pos)
77#define ACMP_CH1_POSPIN_P0 (0UL)
78#define ACMP_CH1_POSPIN_P1 (1UL << ACMP_CTL_POSSEL_Pos)
79#define ACMP_CH1_POSPIN_P2 (2UL << ACMP_CTL_POSSEL_Pos)
80#define ACMP_CH1_POSPIN_P3 (3UL << ACMP_CTL_POSSEL_Pos)
81#define ACMP_CH1_POS_OPA1 (4UL << ACMP_CTL_POSSEL_Pos)
82#define ACMP_CH2_POSPIN_P0 (0UL)
83#define ACMP_CH2_POSPIN_P1 (1UL << ACMP_CTL_POSSEL_Pos)
84#define ACMP_CH2_POSPIN_P2 (2UL << ACMP_CTL_POSSEL_Pos)
85#define ACMP_CH2_POSPIN_P3 (3UL << ACMP_CTL_POSSEL_Pos)
86
87 /* end of group NUC472_442_ACMP_EXPORTED_CONSTANTS */
89
90
139#define ACMP_SET_NEG_SRC(acmp, u32ChNum, u32Src) do{\
140 if(u32Src == ACMP_VNEG_PIN)\
141 ACMP->CTL[u32ChNum] &= ~ACMP_CTL_NEGSEL_Msk;\
142 else {\
143 ACMP->CTL[u32ChNum] |= ACMP_CTL_NEGSEL_Msk;\
144 ACMP->VREF = u32Src;\
145 }\
146 }while(0)
147
155#define ACMP_ENABLE_HYSTERESIS(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_HYSEN_Msk)
156
164#define ACMP_DISABLE_HYSTERESIS(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_HYSEN_Msk)
165
173#define ACMP_ENABLE_INT(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_ACMPIE_Msk)
174
182#define ACMP_DISABLE_INT(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_ACMPIE_Msk)
183
184
192#define ACMP_ENABLE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_ACMPEN_Msk)
193
201#define ACMP_DISABLE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_ACMPEN_Msk)
202
210#define ACMP_GET_OUTPUT(acmp, u32ChNum) (ACMP->STATUS & (ACMP_STATUS_ACMPO0_Msk<<(u32ChNum))?1:0)
211
219#define ACMP_GET_INT_FLAG(acmp, u32ChNum) (ACMP->STATUS & (ACMP_STATUS_ACMPIF0_Msk<<(u32ChNum))?1:0)
220
228#define ACMP_CLR_INT_FLAG(acmp, u32ChNum) (ACMP->STATUS = (ACMP_STATUS_ACMPIF0_Msk<<(u32ChNum)))
229
243#define ACMP_SELECT_P(acmp, u32ChNum, u32Pin) (ACMP->CTL[u32ChNum] = (ACMP->CTL[u32ChNum] & ~ACMP_CTL_POSSEL_Msk) | u32Pin)
284#define ACMP_CRV_SEL(acmp, u32Level) (ACMP->VREF = (ACMP->VREF & ~(ACMP_VREF_CRVSSEL_Msk | ACMP_VREF_CRVCTL_Msk)) | (u32Level))
291#define ACMP_ENABLE_CRV(acmp) (ACMP->VREF |= ACMP_VREF_IREFSEL_Msk)
298#define ACMP_DISABLE_CRV(acmp) (ACMP->VREF &= ~ACMP_VREF_IREFSEL_Msk)
299
307#define ACMP_ENABLE_OUTPUT_INVERSE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_ACMPOINV_Msk)
308
316#define ACMP_DISABLE_OUTPUT_INVERSE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_ACMPOINV_Msk)
317
318
319 void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn);
320 void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum);
321 /* end of group NUC472_442_ACMP_EXPORTED_FUNCTIONS */
323 /* end of group NUC472_442_ACMP_Driver */
325 /* end of group NUC472_442_Device_Driver */
327
328#ifdef __cplusplus
329}
330#endif
331
332#endif //__ACMP_H__
333
334/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
ACMP_Open
void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn)
Configure the specified ACMP module.
Definition: acmp.c:80
ACMP_Close
void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum)
This function close comparator.
Definition: acmp.c:96
ACMP_T
Definition: NUC472_442.h:223