| MINI58_BSP V3.01.003 The Board Support Package for Mini58 Series MCU

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
34#define ACMP_VNEG_PIN (0xFFUL)
35#define ACMP_VNEG_BANDGAP (0x00UL)
36#define ACMP_VNEG_4_OVER_24_VDD (0x80UL)
37#define ACMP_VNEG_5_OVER_24_VDD (0x81UL)
38#define ACMP_VNEG_6_OVER_24_VDD (0x82UL)
39#define ACMP_VNEG_7_OVER_24_VDD (0x83UL)
40#define ACMP_VNEG_8_OVER_24_VDD (0x84UL)
41#define ACMP_VNEG_9_OVER_24_VDD (0x85UL)
42#define ACMP_VNEG_10_OVER_24_VDD (0x86UL)
43#define ACMP_VNEG_11_OVER_24_VDD (0x87UL)
44#define ACMP_VNEG_12_OVER_24_VDD (0x88UL)
45#define ACMP_VNEG_13_OVER_24_VDD (0x89UL)
46#define ACMP_VNEG_14_OVER_24_VDD (0x8AUL)
47#define ACMP_VNEG_15_OVER_24_VDD (0x8BUL)
48#define ACMP_VNEG_16_OVER_24_VDD (0x8CUL)
49#define ACMP_VNEG_17_OVER_24_VDD (0x8DUL)
50#define ACMP_VNEG_18_OVER_24_VDD (0x8EUL)
51#define ACMP_VNEG_19_OVER_24_VDD (0x8FUL)
52#define ACMP_HYSTERESIS_ENABLE (1UL << ACMP_CTL_HYSSEL_Pos)
53#define ACMP_HYSTERESIS_DISABLE (0UL)
54#define ACMP_CH0_POSPIN_P15 (0UL)
55#define ACMP_CH0_POSPIN_P10 (1UL << ACMP_CTL_POSSEL_Pos)
56#define ACMP_CH0_POSPIN_P12 (2UL << ACMP_CTL_POSSEL_Pos)
57#define ACMP_CH0_POSPIN_P13 (3UL << ACMP_CTL_POSSEL_Pos)
58#define ACMP_CH1_POSPIN_P31 (0UL)
59#define ACMP_CH1_POSPIN_P32 (1UL << ACMP_CTL_POSSEL_Pos)
60#define ACMP_CH1_POSPIN_P34 (2UL << ACMP_CTL_POSSEL_Pos)
61#define ACMP_CH1_POSPIN_P35 (3UL << ACMP_CTL_POSSEL_Pos)
62#define ACMP_FILTSEL_OFF (0UL)
63#define ACMP_FILTSEL_1PCLK (1UL << ACMP_CTL_FILTSEL_Pos)
64#define ACMP_FILTSEL_2PCLK (2UL << ACMP_CTL_FILTSEL_Pos)
65#define ACMP_FILTSEL_4PCLK (3UL << ACMP_CTL_FILTSEL_Pos)
66#define ACMP_FILTSEL_8PCLK (4UL << ACMP_CTL_FILTSEL_Pos)
67#define ACMP_FILTSEL_16PCLK (5UL << ACMP_CTL_FILTSEL_Pos)
68#define ACMP_FILTSEL_32PCLK (6UL << ACMP_CTL_FILTSEL_Pos)
69#define ACMP_FILTSEL_64PCLK (7UL << ACMP_CTL_FILTSEL_Pos)
70#define ACMP_FILTSEL_128PCLK (8UL << ACMP_CTL_FILTSEL_Pos)
71#define ACMP_FILTSEL_256PCLK (9UL << ACMP_CTL_FILTSEL_Pos)
72#define ACMP_FILTSEL_512PCLK (10UL << ACMP_CTL_FILTSEL_Pos)
73 /* end of group Mini58_ACMP_EXPORTED_CONSTANTS */
75
76
109#define ACMP_SET_NEG_SRC(acmp, u32ChNum, u32Src) do{\
110 if(u32Src == ACMP_VNEG_PIN)\
111 ACMP->CTL[u32ChNum] &= ~ACMP_CTL_NEGSEL_Msk;\
112 else {\
113 ACMP->CTL[u32ChNum] |= ACMP_CTL_NEGSEL_Msk;\
114 ACMP->VREF = u32Src;\
115 }\
116 }while(0)
117
125#define ACMP_ENABLE_HYSTERESIS(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_HYSSEL_Msk)
126
134#define ACMP_DISABLE_HYSTERESIS(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_HYSSEL_Msk)
135
143#define ACMP_ENABLE_INT(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_ACMPIE_Msk)
144
152#define ACMP_DISABLE_INT(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_ACMPIE_Msk)
153
154
162#define ACMP_ENABLE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_ACMPEN_Msk)
163
171#define ACMP_DISABLE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_ACMPEN_Msk)
172
180#define ACMP_GET_OUTPUT(acmp, u32ChNum) (ACMP->STATUS & (ACMP_STATUS_ACMPO0_Msk<<(u32ChNum))?1:0)
181
189#define ACMP_GET_INT_FLAG(acmp, u32ChNum) (ACMP->STATUS & (ACMP_STATUS_ACMPIF0_Msk<<(u32ChNum))?1:0)
190
198#define ACMP_CLR_INT_FLAG(acmp, u32ChNum) (ACMP->STATUS = (ACMP_STATUS_ACMPIF0_Msk<<(u32ChNum)))
199
212#define ACMP_SELECT_P(acmp, u32ChNum, u32Pin) (ACMP->CTL[u32ChNum] = (ACMP->CTL[u32ChNum] & ~ACMP_CTL_POSSEL_Msk) | (u32Pin))
236#define ACMP_CRV_SEL(acmp, u32Level) (ACMP->VREF = (ACMP->VREF & ~ACMP_VREF_CRVCTL_Msk) | ((u32Level) & ~ACMP_VREF_IREFSEL_Msk))
243#define ACMP_ENABLE_CRV(acmp) (ACMP->VREF |= ACMP_VREF_IREFSEL_Msk)
250#define ACMP_DISABLE_CRV(acmp) (ACMP->VREF &= ~ACMP_VREF_IREFSEL_Msk)
251
259#define ACMP_ENABLE_FALLING_EDGE_TRIGGER(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_FTRGEN_Msk)
260
268#define ACMP_DISABLE_FALLING_EDGE_TRIGGER(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_FTRGEN_Msk)
269
277#define ACMP_ENABLE_RISING_EDGE_TRIGGER(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_RTRGEN_Msk)
278
286#define ACMP_DISABLE_RISING_EDGE_TRIGGER(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_RTRGEN_Msk)
287
307#define ACMP_SET_FILTER(acmp, u32ChNum, u32Cnt) ((acmp)->CTL[(u32ChNum)] = ((acmp)->CTL[u32ChNum] & ~ACMP_CTL_FILTSEL_Msk) | (u32Cnt))
308
309 void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn);
310 void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum);
311 /* end of group Mini58_ACMP_EXPORTED_FUNCTIONS */
313 /* end of group Mini58_ACMP_Driver */
315 /* end of group Mini58_Device_Driver */
317
318#ifdef __cplusplus
319}
320#endif
321
322#endif //__ACMP_H__
323
324/*** (C) COPYRIGHT 2022 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:64
ACMP_Close
void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum)
This function close comparator.
Definition: acmp.c:80
ACMP_T
Definition: Mini58Series.h:163