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 "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_in.h"
49 
50 // -------------------------------------------------------------- PUBLIC MACROS
60 #define COMPARATOR_MAP_MIKROBUS( cfg, mikrobus ) \
61  cfg.o1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
62  cfg.o2 = MIKROBUS( mikrobus, MIKROBUS_INT )
63 
69 #define COMPARATOR_RETVAL uint8_t
70 
71 #define COMPARATOR_OK 0x00
72 #define COMPARATOR_INIT_ERROR 0xFF
73 
79 #define COMPARATOR_STATE_LOW 0x00
80 #define COMPARATOR_STATE_HIGH 0x01
81  // End group macro
84 
85 // --------------------------------------------------------------- PUBLIC TYPES
94 typedef struct
95 {
96 
97  // Input pins
98 
99  digital_in_t o1;
100  digital_in_t o2;
101 
102 } comparator_t;
103 
107 typedef struct
108 {
109  // Additional gpio pins
110 
111  pin_name_t o1;
112  pin_name_t o2;
113 
115  // End types group
117 
118 // ------------------------------------------------------------------ CONSTANTS // End constants group
126 
127 // ------------------------------------------------------------------ VARIABLES // End variable group
135 
136 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
137 
143 #ifdef __cplusplus
144 extern "C"{
145 #endif
146 
156 
166 
181 
196 
197 #ifdef __cplusplus
198 }
199 #endif
200 #endif // _COMPARATOR_H_
201  // End public_function group
204 
205 // ------------------------------------------------------------------------- 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:99
comparator_cfg_t::o2
pin_name_t o2
Definition: comparator.h:112
comparator_cfg_t
Click configuration structure definition.
Definition: comparator.h:108
COMPARATOR_RETVAL
#define COMPARATOR_RETVAL
Definition: comparator.h:69
comparator_t
Click ctx object definition.
Definition: comparator.h:95
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:111
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:100
comparator_check_output_one
uint8_t comparator_check_output_one(comparator_t *ctx)
Check state of the o1 pin function.