diffpress  2.0.0.0
diffpress.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 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef DIFFPRESS_H
36 #define DIFFPRESS_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_i2c_master.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define DIFFPRESS_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
53  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
54 
60 #define DIFFPRESS_RETVAL uint8_t
61 
62 #define DIFFPRESS_OK 0x00
63 #define DIFFPRESS_INIT_ERROR 0xFF
64 
70 #define DIFFPRESS_DEVICE_ADDRESS 0x4D
71  // End group macro
74 // --------------------------------------------------------------- PUBLIC TYPES
83 typedef struct
84 {
85  // Modules
86 
87  i2c_master_t i2c;
88 
89  // ctx variable
90 
91  uint8_t slave_address;
92 
93 } diffpress_t;
94 
98 typedef struct
99 {
100  // Communication gpio pins
101 
102  pin_name_t scl;
103  pin_name_t sda;
104 
105  // static variable
106 
107  uint32_t i2c_speed;
108  uint8_t i2c_address;
109 
111  // End types group
113 
114 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
115 
121 #ifdef __cplusplus
122 extern "C"{
123 #endif
124 
134 
144 
145 
154 
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 #endif // _DIFFPRESS_H_
168  // End public_function group
171 
172 // ------------------------------------------------------------------------- END
diffpress_cfg_t::sda
pin_name_t sda
Definition: diffpress.h:103
diffpress_get_adc_data
uint16_t diffpress_get_adc_data(diffpress_t *ctx)
Gets adc data function.
DIFFPRESS_RETVAL
#define DIFFPRESS_RETVAL
Definition: diffpress.h:60
diffpress_t::i2c
i2c_master_t i2c
Definition: diffpress.h:87
diffpress_cfg_setup
void diffpress_cfg_setup(diffpress_cfg_t *cfg)
Config Object Initialization function.
diffpress_get_pressure_difference
float diffpress_get_pressure_difference(diffpress_t *ctx)
Gets pressure difference function.
diffpress_cfg_t::i2c_address
uint8_t i2c_address
Definition: diffpress.h:108
diffpress_cfg_t
Click configuration structure definition.
Definition: diffpress.h:99
diffpress_t
Click ctx object definition.
Definition: diffpress.h:84
diffpress_cfg_t::scl
pin_name_t scl
Definition: diffpress.h:102
diffpress_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: diffpress.h:107
diffpress_init
DIFFPRESS_RETVAL diffpress_init(diffpress_t *ctx, diffpress_cfg_t *cfg)
Initialization function.
diffpress_t::slave_address
uint8_t slave_address
Definition: diffpress.h:91