| Nano103 BSP V3.01.002 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
16 extern "C"
17 {
18 #endif
19
80 void 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
98 void 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
ACMP_T::VREF
__IO uint32_t VREF
Definition: Nano103.h:24749
ACMP_CTL0_ACMPEN_Msk
#define ACMP_CTL0_ACMPEN_Msk
Definition: Nano103.h:24759
ACMP_T
Definition: Nano103.h:24621
ACMP_Open
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
Nano103.h
NANO103 peripheral access layer header file. This file contains all the peripheral register's definit...
ACMP_T::CTL0
__IO uint32_t CTL0
Definition: Nano103.h:24747
ACMP_Close
void ACMP_Close(ACMP_T *acmp, uint32_t u32ChNum)
This function close comparator.
Definition: acmp.c:98
ACMP_VREF_CRVEN_Msk
#define ACMP_VREF_CRVEN_Msk
Definition: Nano103.h:24783
ACMP_CTL0_NEGSEL_Pos
#define ACMP_CTL0_NEGSEL_Pos
Definition: Nano103.h:24767