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 
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_digital_out.h"
53 #include "drv_i2c_master.h"
54 
55 // -------------------------------------------------------------- PUBLIC MACROS
65 #define DIFFPRESS_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
67  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
68 
74 #define DIFFPRESS_RETVAL uint8_t
75 
76 #define DIFFPRESS_OK 0x00
77 #define DIFFPRESS_INIT_ERROR 0xFF
78 
84 #define DIFFPRESS_DEVICE_ADDRESS 0x4D
85  // End group macro
88 // --------------------------------------------------------------- PUBLIC TYPES
97 typedef struct
98 {
99  // Modules
100 
101  i2c_master_t i2c;
102 
103  // ctx variable
104 
105  uint8_t slave_address;
106 
107 } diffpress_t;
108 
112 typedef struct
113 {
114  // Communication gpio pins
115 
116  pin_name_t scl;
117  pin_name_t sda;
118 
119  // static variable
120 
121  uint32_t i2c_speed;
122  uint8_t i2c_address;
123 
125  // End types group
127 
128 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
129 
135 #ifdef __cplusplus
136 extern "C"{
137 #endif
138 
148 
158 
159 
168 
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 #endif // _DIFFPRESS_H_
182  // End public_function group
185 
186 // ------------------------------------------------------------------------- END
diffpress_cfg_t::sda
pin_name_t sda
Definition: diffpress.h:117
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:74
diffpress_t::i2c
i2c_master_t i2c
Definition: diffpress.h:101
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:122
diffpress_cfg_t
Click configuration structure definition.
Definition: diffpress.h:113
diffpress_t
Click ctx object definition.
Definition: diffpress.h:98
diffpress_cfg_t::scl
pin_name_t scl
Definition: diffpress.h:116
diffpress_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: diffpress.h:121
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:105