pressure12  2.0.0.0
pressure12.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 PRESSURE12_H
36 #define PRESSURE12_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_analog_in.h"
49 
50 // -------------------------------------------------------------- PUBLIC MACROS
51 
61 #define PRESSURE12_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
63  // End group macro
66 // --------------------------------------------------------------- PUBLIC TYPES
75 typedef struct
76 {
77  // Modules
78 
79  analog_in_t adc;
80 
81 } pressure12_t;
82 
86 typedef struct
87 {
88  // Communication gpio pins
89 
90  pin_name_t an_pin;
91 
92  // Config variables
93 
94  analog_in_resolution_t resolution;
95  float vref;
98  // End types group
100 
101 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
102 
108 #ifdef __cplusplus
109 extern "C"{
110 #endif
111 
122 
137 
148 err_t pressure12_read_pin_adc ( pressure12_t *ctx, uint16_t *data_out );
149 
160 err_t pressure12_read_pin_voltage ( pressure12_t *ctx, float *data_out );
161 
173 err_t pressure12_get_pressure ( pressure12_t *ctx, uint16_t *data_out );
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 #endif // _PRESSURE12_H_
179  // End public_function group
182 
183 // ------------------------------------------------------------------------ END
pressure12_cfg_t::vref
float vref
Definition: pressure12.h:95
pressure12_cfg_t::an_pin
pin_name_t an_pin
Definition: pressure12.h:90
pressure12_cfg_t
Click configuration structure definition.
Definition: pressure12.h:87
pressure12_read_pin_adc
err_t pressure12_read_pin_adc(pressure12_t *ctx, uint16_t *data_out)
Generic read function.
pressure12_get_pressure
err_t pressure12_get_pressure(pressure12_t *ctx, uint16_t *data_out)
Get pressure function.
pressure12_read_pin_voltage
err_t pressure12_read_pin_voltage(pressure12_t *ctx, float *data_out)
Generic function for read voltage.
pressure12_t::adc
analog_in_t adc
Definition: pressure12.h:79
pressure12_cfg_t::resolution
analog_in_resolution_t resolution
Definition: pressure12.h:94
pressure12_cfg_setup
void pressure12_cfg_setup(pressure12_cfg_t *cfg)
Config Object Initialization function.
pressure12_init
err_t pressure12_init(pressure12_t *ctx, pressure12_cfg_t *cfg)
Initialization function.
pressure12_t
Click ctx object definition.
Definition: pressure12.h:76