comparator  2.0.0.0
comparator.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef COMPARATOR_H
36 #define COMPARATOR_H
37 
38 #include "drv_digital_in.h"
39 
40 // -------------------------------------------------------------- PUBLIC MACROS
50 #define COMPARATOR_MAP_MIKROBUS( cfg, mikrobus ) \
51  cfg.o1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
52  cfg.o2 = MIKROBUS( mikrobus, MIKROBUS_INT )
53 
59 #define COMPARATOR_RETVAL uint8_t
60 
61 #define COMPARATOR_OK 0x00
62 #define COMPARATOR_INIT_ERROR 0xFF
63 
69 #define COMPARATOR_STATE_LOW 0x00
70 #define COMPARATOR_STATE_HIGH 0x01
71  // End group macro
74 
75 // --------------------------------------------------------------- PUBLIC TYPES
84 typedef struct
85 {
86 
87  // Input pins
88 
89  digital_in_t o1;
90  digital_in_t o2;
91 
92 } comparator_t;
93 
97 typedef struct
98 {
99  // Additional gpio pins
100 
101  pin_name_t o1;
102  pin_name_t o2;
103 
105  // End types group
107 
108 // ------------------------------------------------------------------ CONSTANTS // End constants group
116 
117 // ------------------------------------------------------------------ VARIABLES // End variable group
125 
126 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
127 
133 #ifdef __cplusplus
134 extern "C"{
135 #endif
136 
146 
156 
171 
186 
187 #ifdef __cplusplus
188 }
189 #endif
190 #endif // _COMPARATOR_H_
191  // End public_function group
194 
195 // ------------------------------------------------------------------------- END
comparator_check_output_two
uint8_t comparator_check_output_two(comparator_t *ctx)
Check state of the o2 pin function.
comparator_t::o1
digital_in_t o1
Definition: comparator.h:89
comparator_cfg_t::o2
pin_name_t o2
Definition: comparator.h:102
comparator_cfg_t
Click configuration structure definition.
Definition: comparator.h:97
COMPARATOR_RETVAL
#define COMPARATOR_RETVAL
Definition: comparator.h:59
comparator_t
Click ctx object definition.
Definition: comparator.h:84
comparator_cfg_setup
void comparator_cfg_setup(comparator_cfg_t *cfg)
Config Object Initialization function.
comparator_cfg_t::o1
pin_name_t o1
Definition: comparator.h:101
comparator_init
COMPARATOR_RETVAL comparator_init(comparator_t *ctx, comparator_cfg_t *cfg)
Initialization function.
comparator_t::o2
digital_in_t o2
Definition: comparator.h:90
comparator_check_output_one
uint8_t comparator_check_output_one(comparator_t *ctx)
Check state of the o1 pin function.