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 
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_analog_in.h"
53 
54 // -------------------------------------------------------------- PUBLIC MACROS
55 
65 #define PRESSURE12_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.an_pin = MIKROBUS( mikrobus, MIKROBUS_AN )
67  // End group macro
70 // --------------------------------------------------------------- PUBLIC TYPES
79 typedef struct
80 {
81  // Modules
82 
83  analog_in_t adc;
84 
85 } pressure12_t;
86 
90 typedef struct
91 {
92  // Communication gpio pins
93 
94  pin_name_t an_pin;
95 
96  // Config variables
97 
98  analog_in_resolution_t resolution;
99  float vref;
102  // End types group
104 
105 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
106 
112 #ifdef __cplusplus
113 extern "C"{
114 #endif
115 
126 
141 
152 err_t pressure12_read_pin_adc ( pressure12_t *ctx, uint16_t *data_out );
153 
164 err_t pressure12_read_pin_voltage ( pressure12_t *ctx, float *data_out );
165 
177 err_t pressure12_get_pressure ( pressure12_t *ctx, uint16_t *data_out );
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 #endif // _PRESSURE12_H_
183  // End public_function group
186 
187 // ------------------------------------------------------------------------ END
pressure12_cfg_t::vref
float vref
Definition: pressure12.h:99
pressure12_cfg_t::an_pin
pin_name_t an_pin
Definition: pressure12.h:94
pressure12_cfg_t
Click configuration structure definition.
Definition: pressure12.h:91
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:83
pressure12_cfg_t::resolution
analog_in_resolution_t resolution
Definition: pressure12.h:98
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:80