ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
fw_cmp.h
Go to the documentation of this file.
1// Copyright 2021 IOsetting <iosetting(at)outlook.com>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef ___FW_CMP_H___
16#define ___FW_CMP_H___
17
18#include "fw_conf.h"
19#include "fw_types.h"
20
46typedef enum
47{
51
52typedef enum
53{
57
58typedef enum
59{
65
66typedef enum
67{
71
72typedef enum
73{
79
80#define CMP_SetEnabled(__STATE__) SFR_ASSIGN(CMPCR1, 7, __STATE__)
81#define CMP_ClearInterrupt() SFR_ASSIGN(CMPCR1, 6, 0)
86#define CMP_OLD_SetPositiveInput(__INPUT__) SFR_ASSIGN(CMPCR1, 3, __INPUT__)
91#define CMP_SetPositiveInput(__INPUT__) do{ \
92 SFRX_ON(); \
93 CMPEXCFG = CMPEXCFG & ~(0x03) | (__INPUT__ & 0x03); \
94 SFRX_OFF(); \
95 } while(0)
100#define CMP_OLD_SetNegativeInput(__INPUT__) SFR_ASSIGN(CMPCR1, 2, __INPUT__)
105#define CMP_SetNegativeInput(__INPUT__) SFRX_ASSIGN(CMPEXCFG, 2, __INPUT__)
106
111#define CMP_SetResultOutputState(__STATE__) SFR_ASSIGN(CMPCR1, 1, __STATE__)
112#define CMP_ReadResultOutput() (CMPCR1 & 0x01)
117#define CMP_SetResultOutputInvert(__STATE__) SFR_ASSIGN(CMPCR2, 7, __STATE__)
122#define CMP_SetFilterDisabled(__STATE__) SFR_ASSIGN(CMPCR2, 6, __STATE__)
126#define CMP_SetDebouncingClocks(__CLOCKS__) CMPCR2 = CMPCR2 & ~(0x3F) | (__CLOCKS__ & 0x3F)
130#define CMP_SetHysteresis(__HYST__) do{ \
131 SFRX_ON(); \
132 CMPEXCFG = CMPEXCFG & ~(0x03 << 6) | (__HYST__ << 6); \
133 SFRX_OFF(); \
134 } while(0)
135
136#endif
CMP_PositiveInput_t
Definition: fw_cmp.h:59
@ CMP_PositiveInput_P51
Definition: fw_cmp.h:62
@ CMP_PositiveInput_ADC
Definition: fw_cmp.h:63
@ CMP_PositiveInput_P37
Definition: fw_cmp.h:60
@ CMP_PositiveInput_P50
Definition: fw_cmp.h:61
CMP_NegativeInput_t
Definition: fw_cmp.h:67
@ CMP_NegativeInput_RefV
Definition: fw_cmp.h:69
@ CMP_NegativeInput_P36
Definition: fw_cmp.h:68
CMP_OLD_NegativeInput_t
Definition: fw_cmp.h:53
@ CMP_OLD_NegativeInput_RefV
Definition: fw_cmp.h:54
@ CMP_OLD_NegativeInput_P36
Definition: fw_cmp.h:55
CMP_OLD_PositiveInput_t
Definition: fw_cmp.h:47
@ CMP_OLD_PositiveInput_ADC
Definition: fw_cmp.h:49
@ CMP_OLD_PositiveInput_P37
Definition: fw_cmp.h:48
CMP_Hysteresis_t
Definition: fw_cmp.h:73
@ CMP_Hysteresis_20mV
Definition: fw_cmp.h:76
@ CMP_Hysteresis_30mV
Definition: fw_cmp.h:77
@ CMP_Hysteresis_0mV
Definition: fw_cmp.h:74
@ CMP_Hysteresis_10mV
Definition: fw_cmp.h:75