NANO103 BSP V3.01.004
The Board Support Package for Nano103 Series
acmp.c
Go to the documentation of this file.
1/**************************************************************************/
13#include "Nano103.h"
14
15#ifdef __cplusplus
16extern "C"
17{
18#endif
19
80void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn)
81{
82 if(u32NegSrc & 0x80000000) // one of ACMP_VNEG_PIN, ACMP_VNEG_IREF, ACMP_VNEG_AVSS
83 {
84 acmp->CTL0 = ~(u32NegSrc) | u32HysteresisEn | ACMP_CTL0_ACMPEN_Msk;
85 }
86 else
87 {
88 acmp->CTL0 = (1 << ACMP_CTL0_NEGSEL_Pos) | u32HysteresisEn | ACMP_CTL0_ACMPEN_Msk;
89 acmp->VREF = u32NegSrc | ACMP_VREF_CRVEN_Msk;
90 }
91}
92
98void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum)
99{
100 acmp->CTL0 &= ~ACMP_CTL0_ACMPEN_Msk;
101}
102
103
104 /* end of group NANO103_ACMP_EXPORTED_FUNCTIONS */
106 /* end of group NANO103_ACMP_Driver */
108 /* end of group NANO103_Device_Driver */
110
111#ifdef __cplusplus
112}
113#endif
114
115/*** (C) COPYRIGHT 2015 Nuvoton Technology Corp. ***/
116
NANO103 peripheral access layer header file. This file contains all the peripheral register's definit...
#define ACMP_CTL0_NEGSEL_Pos
Definition: Nano103.h:13685
#define ACMP_VREF_CRVEN_Msk
Definition: Nano103.h:13701
#define ACMP_CTL0_ACMPEN_Msk
Definition: Nano103.h:13677
void ACMP_Open(ACMP_T *acmp, uint32_t u32ChNum, uint32_t u32NegSrc, uint32_t u32HysteresisEn)
This function open and configure comparator parameters.
Definition: acmp.c:80
void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum)
This function close comparator.
Definition: acmp.c:98
__IO uint32_t CTL0
Definition: Nano103.h:13665
__IO uint32_t VREF
Definition: Nano103.h:13667