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 "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_analog_in.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
43 
53 #define TMRMIXSENS_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN ); \
55  cfg.omn = MIKROBUS( mikrobus, MIKROBUS_RST ); \
56  cfg.bi = MIKROBUS( mikrobus, MIKROBUS_CS )
57 
64 #define TMRMIXSENS_RETVAL uint8_t
65 
66 #define TMRMIXSENS_OK 0x00
67 #define TMRMIXSENS_INIT_ERROR 0xFF
68 
74 #define TMRMIXSENS_SOUTH_POLE 0
75 #define TMRMIXSENS_NORTH_POLE 1
76  // End group macro
79 // --------------------------------------------------------------- PUBLIC TYPES
88 typedef uint16_t tmrmixsens_data_t;
89 
93 typedef struct
94 {
95  // Input pins
96 
97  digital_in_t omn;
98  digital_in_t bi;
99 
100  // Modules
101 
102  analog_in_t adc;
103 
104 } tmrmixsens_t;
105 
109 typedef struct
110 {
111  // Communication gpio pins
112 
113  pin_name_t an_pin;
114 
115  // Additional gpio pins
116 
117  pin_name_t omn;
118  pin_name_t bi;
119 
120  // static variable
121 
122  analog_in_resolution_t resolution; // Resolution
123  float vref; // VRef
124 
126  // End types group
128 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
129 
135 #ifdef __cplusplus
136 extern "C"{
137 #endif
138 
148 
158 
168 
184 
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 #endif // _TMRMIXSENS_H_
205  // End public_function group
208 
209 // ------------------------------------------------------------------------ END
tmrmixsens_cfg_t::bi
pin_name_t bi
Definition: tmrmixsens.h:118
tmrmixsens_t::bi
digital_in_t bi
Definition: tmrmixsens.h:98
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:122
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:102
tmrmixsens_t::omn
digital_in_t omn
Definition: tmrmixsens.h:97
tmrmixsens_t
Click ctx object definition.
Definition: tmrmixsens.h:94
tmrmixsens_data_t
uint16_t tmrmixsens_data_t
Analog data type.
Definition: tmrmixsens.h:88
tmrmixsens_cfg_t::omn
pin_name_t omn
Definition: tmrmixsens.h:117
TMRMIXSENS_RETVAL
#define TMRMIXSENS_RETVAL
Definition: tmrmixsens.h:64
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:110
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:113
tmrmixsens_cfg_t::vref
float vref
Definition: tmrmixsens.h:123