blob: f99230f91df71c747669c9660fd31001889e3bc4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/**
******************************************************************************
* @file lib_comp.h
* @author Application Team
* @version V4.4.0
* @date 2018-09-27
* @brief COMP library.
******************************************************************************
* @attention
*
******************************************************************************
*/
#ifndef __LIB_COMP_H
#define __LIB_COMP_H
#ifdef __cplusplus
extern "C" {
#endif
#include "target.h"
/* Macros --------------------------------------------------------------------*/
/***** COMP_DEBConfig *****/
//COMPx
#define COMP_1 (0x00U)
#define COMP_2 (0x02U)
#define IS_COMP(__COMP__) (((__COMP__) == COMP_1) || ((__COMP__) == COMP_2))
//Debounce
#define COMP_DEB_0 ANA_CTRL_CMP1DEB_0
#define COMP_DEB_1 ANA_CTRL_CMP1DEB_1
#define COMP_DEB_2 ANA_CTRL_CMP1DEB_2
#define COMP_DEB_3 ANA_CTRL_CMP1DEB_3
#define IS_COMP_DEB(__DEB__) (((__DEB__) == COMP_DEB_0) ||\
((__DEB__) == COMP_DEB_1) ||\
((__DEB__) == COMP_DEB_2) ||\
((__DEB__) == COMP_DEB_3))
/***** Mode (COMP_ModeConfig) *****/
#define COMP_MODE_OFF ANA_CTRL_COMP1_SEL_0
#define COMP_MODE_RISING ANA_CTRL_COMP1_SEL_1
#define COMP_MODE_FALLING ANA_CTRL_COMP1_SEL_2
#define COMP_MODE_BOTH ANA_CTRL_COMP1_SEL_3
#define IS_COMP_MODE(__MODE__) (((__MODE__) == COMP_MODE_OFF) ||\
((__MODE__) == COMP_MODE_RISING) ||\
((__MODE__) == COMP_MODE_FALLING) ||\
((__MODE__) == COMP_MODE_BOTH))
/***** SourceSelect (COMP_ConfigSignalSource) *****/
#define COMP_SIGNALSRC_P_TO_REF ANA_REG2_CMP1_SEL_0
#define COMP_SIGNALSRC_N_TO_REF ANA_REG2_CMP1_SEL_1
#define COMP_SIGNALSRC_P_TO_N ANA_REG2_CMP1_SEL_2
#define IS_COMP_SIGNALSRC(__SIGNALSRC__) (((__SIGNALSRC__) == COMP_SIGNALSRC_P_TO_REF) ||\
((__SIGNALSRC__) == COMP_SIGNALSRC_N_TO_REF) ||\
((__SIGNALSRC__) == COMP_SIGNALSRC_P_TO_N))
/***** REFSelect (COMP_ConfigREF) *****/
#define COMP_REF_VREF (0)
#define COMP_REF_BGPREF ANA_REG2_REFSEL_CMP1
#define IS_COMP_REF(__REF__) (((__REF__) == COMP_REF_VREF) ||\
((__REF__) == COMP_REF_BGPREF))
/***** BiasSel (COMP_BiasConfig) *****/
#define COMP_BIAS_20nA ANA_REG5_IT_CMP1_0
#define COMP_BIAS_100nA ANA_REG5_IT_CMP1_1
#define COMP_BIAS_500nA ANA_REG5_IT_CMP1_2
#define IS_COMP_BIAS(__BIAS__) (((__BIAS__) == COMP_BIAS_20nA) ||\
((__BIAS__) == COMP_BIAS_100nA)||\
((__BIAS__) == COMP_BIAS_500nA))
/* Exported Functions ------------------------------------------------------- */
void COMP_DEBConfig(uint32_t COMPx, uint32_t Debounce);
void COMP_ModeConfig(uint32_t COMPx, uint32_t Mode);
void COMP_SignalSourceConfig(uint32_t COMPx, uint32_t SourceSelect);
void COMP_REFConfig(uint32_t COMPx, uint32_t REFSelect);
void COMP_BiasConfig(uint32_t COMPx, uint32_t BiasSel);
void COMP_INTConfig(uint32_t COMPx, uint32_t NewState);
uint8_t COMP_GetINTStatus(uint32_t COMPx);
void COMP_ClearINTStatus(uint32_t COMPx);
void COMP_Output_Cmd(uint32_t COMPx, uint32_t NewState);
void COMP_Cmd(uint32_t COMPx, uint32_t NewState);
uint32_t COMP_GetCNTValue(uint32_t COMPx);
void COMP_ClearCNTValue(uint32_t COMPx);
uint8_t COMP1_GetOutputLevel(void);
uint8_t COMP2_GetOutputLevel(void);
#ifdef __cplusplus
}
#endif
#endif /* __LIB_COMP_H */
/*********************************** END OF FILE ******************************/
|