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 
42 #ifdef PREINIT_SUPPORTED
43 #include "preinit.h"
44 #endif
45 
46 #ifdef MikroCCoreVersion
47  #if MikroCCoreVersion >= 1
48  #include "delays.h"
49  #endif
50 #endif
51 
52 #include "drv_digital_in.h"
53 
54 // -------------------------------------------------------------- PUBLIC MACROS
64 #define COMPARATOR_MAP_MIKROBUS( cfg, mikrobus ) \
65  cfg.o1 = MIKROBUS( mikrobus, MIKROBUS_AN ); \
66  cfg.o2 = MIKROBUS( mikrobus, MIKROBUS_INT )
67 
73 #define COMPARATOR_RETVAL uint8_t
74 
75 #define COMPARATOR_OK 0x00
76 #define COMPARATOR_INIT_ERROR 0xFF
77 
83 #define COMPARATOR_STATE_LOW 0x00
84 #define COMPARATOR_STATE_HIGH 0x01
85  // End group macro
88 
89 // --------------------------------------------------------------- PUBLIC TYPES
98 typedef struct
99 {
100 
101  // Input pins
102 
103  digital_in_t o1;
104  digital_in_t o2;
105 
106 } comparator_t;
107 
111 typedef struct
112 {
113  // Additional gpio pins
114 
115  pin_name_t o1;
116  pin_name_t o2;
117 
119  // End types group
121 
122 // ------------------------------------------------------------------ CONSTANTS // End constants group
130 
131 // ------------------------------------------------------------------ VARIABLES // End variable group
139 
140 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
141 
147 #ifdef __cplusplus
148 extern "C"{
149 #endif
150 
160 
170 
185 
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 #endif // _COMPARATOR_H_
205  // End public_function group
208 
209 // ------------------------------------------------------------------------- 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:103
comparator_cfg_t::o2
pin_name_t o2
Definition: comparator.h:116
comparator_cfg_t
Click configuration structure definition.
Definition: comparator.h:112
COMPARATOR_RETVAL
#define COMPARATOR_RETVAL
Definition: comparator.h:73
comparator_t
Click ctx object definition.
Definition: comparator.h:99
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:115
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:104
comparator_check_output_one
uint8_t comparator_check_output_one(comparator_t *ctx)
Check state of the o1 pin function.