tmrmixsens  2.0.0.0
tmrmixsens.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
35 #ifndef TMRMIXSENS_H
36 #define TMRMIXSENS_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_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_analog_in.h"
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
53 
63 #define TMRMIXSENS_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN ); \
65  cfg.omn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
66  cfg.bi = MIKROBUS( mikrobus, MIKROBUS_CS )
67 
74 #define TMRMIXSENS_RETVAL uint8_t
75 
76 #define TMRMIXSENS_OK 0x00
77 #define TMRMIXSENS_INIT_ERROR 0xFF
78 
84 #define TMRMIXSENS_SOUTH_POLE 0
85 #define TMRMIXSENS_NORTH_POLE 1
86  // End group macro
89 // --------------------------------------------------------------- PUBLIC TYPES
98 typedef uint16_t tmrmixsens_data_t;
99 
103 typedef struct
104 {
105  // Input pins
106 
107  digital_in_t omn;
108  digital_in_t bi;
109 
110  // Modules
111 
112  analog_in_t adc;
113 
114 } tmrmixsens_t;
115 
119 typedef struct
120 {
121  // Communication gpio pins
122 
123  pin_name_t an_pin;
124 
125  // Additional gpio pins
126 
127  pin_name_t omn;
128  pin_name_t bi;
129 
130  // static variable
131 
132  analog_in_resolution_t resolution; // Resolution
133  float vref; // VRef
134 
136  // End types group
138 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
139 
145 #ifdef __cplusplus
146 extern "C"{
147 #endif
148 
158 
168 
178 
194 
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 #endif // _TMRMIXSENS_H_
215  // End public_function group
218 
219 // ------------------------------------------------------------------------ END
tmrmixsens_cfg_t::bi
pin_name_t bi
Definition: tmrmixsens.h:128
tmrmixsens_t::bi
digital_in_t bi
Definition: tmrmixsens.h:108
tmrmixsens_cfg_setup
void tmrmixsens_cfg_setup(tmrmixsens_cfg_t *cfg)
Config Object Initialization function.
tmrmixsens_init
TMRMIXSENS_RETVAL tmrmixsens_init(tmrmixsens_t *ctx, tmrmixsens_cfg_t *cfg)
Initialization function.
tmrmixsens_cfg_t::resolution
analog_in_resolution_t resolution
Definition: tmrmixsens.h:132
tmrmixsens_generic_read
tmrmixsens_data_t tmrmixsens_generic_read(tmrmixsens_t *ctx)
Generic read function.
tmrmixsens_t::adc
analog_in_t adc
Definition: tmrmixsens.h:112
tmrmixsens_t::omn
digital_in_t omn
Definition: tmrmixsens.h:107
tmrmixsens_t
Click ctx object definition.
Definition: tmrmixsens.h:104
tmrmixsens_data_t
uint16_t tmrmixsens_data_t
Analog data type.
Definition: tmrmixsens.h:98
tmrmixsens_cfg_t::omn
pin_name_t omn
Definition: tmrmixsens.h:127
TMRMIXSENS_RETVAL
#define TMRMIXSENS_RETVAL
Definition: tmrmixsens.h:74
tmrmixsens_get_bipolar
uint8_t tmrmixsens_get_bipolar(tmrmixsens_t *ctx)
Get state of the bipolar ( BI ) pin function.
tmrmixsens_cfg_t
Click configuration structure definition.
Definition: tmrmixsens.h:120
tmrmixsens_get_omnipolar
uint8_t tmrmixsens_get_omnipolar(tmrmixsens_t *ctx)
Get state of the omnipolar ( OMN ) pin function.
tmrmixsens_cfg_t::an_pin
pin_name_t an_pin
Definition: tmrmixsens.h:123
tmrmixsens_cfg_t::vref
float vref
Definition: tmrmixsens.h:133