| MINI55_BSP V3.01.003 The Board Support Package for Mini55 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
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_HYSTERESIS_ENABLE_15mv (1UL << ACMP_CTL_HYSSEL_Pos)
55#define ACMP_HYSTERESIS_ENABLE_90mv (2UL << ACMP_CTL_HYSSEL_Pos)
56#define ACMP_HYSTERESIS_DISABLE (0UL)
57#define ACMP_CH0_POSPIN_P15 (0UL)
58#define ACMP_CH0_POSPIN_P10 (1UL << ACMP_CTL_POSSEL_Pos)
59#define ACMP_CH0_POSPIN_P12 (2UL << ACMP_CTL_POSSEL_Pos)
60#define ACMP_CH0_POSPIN_P13 (3UL << ACMP_CTL_POSSEL_Pos)
61#define ACMP_CH1_POSPIN_P31 (0UL)
62#define ACMP_CH1_POSPIN_P32 (1UL << ACMP_CTL_POSSEL_Pos)
63#define ACMP_CH1_POSPIN_P34 (2UL << ACMP_CTL_POSSEL_Pos)
64#define ACMP_CH1_POSPIN_P35 (3UL << ACMP_CTL_POSSEL_Pos)
65
66 /* end of group MINI55_ACMP_EXPORTED_CONSTANTS */
68
69
102#define ACMP_SET_NEG_SRC(acmp, u32ChNum, u32Src) do{\
103 if(u32Src == ACMP_VNEG_PIN)\
104 ACMP->CTL[u32ChNum] &= ~ACMP_CTL_NEGSEL_Msk;\
105 else {\
106 ACMP->CTL[u32ChNum] |= ACMP_CTL_NEGSEL_Msk;\
107 ACMP->VREF = u32Src;\
108 }\
109 }while(0)
110
118#define ACMP_ENABLE_HYSTERESIS(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_HYSSEL_Msk)
119
127#define ACMP_DISABLE_HYSTERESIS(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_HYSSEL_Msk)
128
136#define ACMP_ENABLE_INT(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_ACMPIE_Msk)
137
145#define ACMP_DISABLE_INT(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_ACMPIE_Msk)
146
147
155#define ACMP_ENABLE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_ACMPEN_Msk)
156
164#define ACMP_DISABLE(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_ACMPEN_Msk)
165
173#define ACMP_GET_OUTPUT(acmp, u32ChNum) (ACMP->STATUS & (ACMP_STATUS_ACMPO0_Msk<<(u32ChNum))?1:0)
174
182#define ACMP_GET_INT_FLAG(acmp, u32ChNum) (ACMP->STATUS & (ACMP_STATUS_ACMPIF0_Msk<<(u32ChNum))?1:0)
183
191#define ACMP_CLR_INT_FLAG(acmp, u32ChNum) (ACMP->STATUS = (ACMP_STATUS_ACMPIF0_Msk<<(u32ChNum)))
192
205#define ACMP_SELECT_P(acmp, u32ChNum, u32Pin) (ACMP->CTL[u32ChNum] = (ACMP->CTL[u32ChNum] & ~ACMP_CTL_POSSEL_Msk) | u32Pin)
229#define ACMP_CRV_SEL(acmp, u32Level) (ACMP->VREF = (ACMP->VREF & ~ACMP_VREF_CRVCTL_Msk) | (u32Level & ~ACMP_VREF_IREFSEL_Msk))
236#define ACMP_ENABLE_CRV(acmp) (ACMP->VREF |= ACMP_VREF_IREFSEL_Msk)
243#define ACMP_DISABLE_CRV(acmp) (ACMP->VREF &= ~ACMP_VREF_IREFSEL_Msk)
244
252#define ACMP_ENABLE_FALLING_EDGE_TRIGGER(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_FTRGEN_Msk)
253
261#define ACMP_DISABLE_FALLING_EDGE_TRIGGER(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_FTRGEN_Msk)
262
270#define ACMP_ENABLE_RISING_EDGE_TRIGGER(acmp, u32ChNum) (ACMP->CTL[u32ChNum] |= ACMP_CTL_RTRGEN_Msk)
271
278#define ACMP_DISABLE_RISING_EDGE_TRIGGER(acmp, u32ChNum) (ACMP->CTL[u32ChNum] &= ~ACMP_CTL_RTRGEN_Msk)
279
280 void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn);
281 void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum);
282 /* end of group MINI55_ACMP_EXPORTED_FUNCTIONS */
284 /* end of group MINI55_ACMP_Driver */
286 /* end of group MINI55_Device_Driver */
288
289#ifdef __cplusplus
290}
291#endif
292
293#endif //__ACMP_H__
294
295/*** (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:64
ACMP_Close
void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum)
This function close comparator.
Definition: acmp.c:80
ACMP_T
Definition: Mini55Series.h:163