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 "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_i2c_master.h"
50 
51 // -------------------------------------------------------------- PUBLIC MACROS
61 #define DIFFPRESS_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
63  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
64 
70 #define DIFFPRESS_RETVAL uint8_t
71 
72 #define DIFFPRESS_OK 0x00
73 #define DIFFPRESS_INIT_ERROR 0xFF
74 
80 #define DIFFPRESS_DEVICE_ADDRESS 0x4D
81  // End group macro
84 // --------------------------------------------------------------- PUBLIC TYPES
93 typedef struct
94 {
95  // Modules
96 
97  i2c_master_t i2c;
98 
99  // ctx variable
100 
101  uint8_t slave_address;
102 
103 } diffpress_t;
104 
108 typedef struct
109 {
110  // Communication gpio pins
111 
112  pin_name_t scl;
113  pin_name_t sda;
114 
115  // static variable
116 
117  uint32_t i2c_speed;
118  uint8_t i2c_address;
119 
121  // End types group
123 
124 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
125 
131 #ifdef __cplusplus
132 extern "C"{
133 #endif
134 
144 
154 
155 
164 
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 #endif // _DIFFPRESS_H_
178  // End public_function group
181 
182 // ------------------------------------------------------------------------- END
diffpress_cfg_t::sda
pin_name_t sda
Definition: diffpress.h:113
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:70
diffpress_t::i2c
i2c_master_t i2c
Definition: diffpress.h:97
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:118
diffpress_cfg_t
Click configuration structure definition.
Definition: diffpress.h:109
diffpress_t
Click ctx object definition.
Definition: diffpress.h:94
diffpress_cfg_t::scl
pin_name_t scl
Definition: diffpress.h:112
diffpress_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: diffpress.h:117
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:101