pressure8  2.0.0.0
pressure8.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 PRESSURE8_H
36 #define PRESSURE8_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_digital_in.h"
54 #include "drv_i2c_master.h"
55 
56 
57 // -------------------------------------------------------------- PUBLIC MACROS
67 #define PRESSURE8_MAP_MIKROBUS( cfg, mikrobus ) \
68  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
71  cfg.eoc = MIKROBUS( mikrobus, MIKROBUS_INT )
72 
78 #define PRESSURE8_OK 0
79 #define PRESSURE8_ERROR -1
80 
86 #define PRESSURE8_DATA_IN_MBAR 1
87 #define PRESSURE8_DATA_IN_HPA 2
88 #define PRESSURE8_DATA_IN_KPA 3
89 #define PRESSURE8_DATA_IN_TORR 4
90 #define PRESSURE8_DATA_IN_MMHG 5
91  // End group macro
94 // --------------------------------------------------------------- PUBLIC TYPES
103 typedef struct
104 {
105  // Output pins
106  digital_out_t rst;
107 
108  // Input pins
109  digital_in_t eoc;
110 
111  // Modules
112  i2c_master_t i2c;
113 
114  // ctx variable
115  uint8_t slave_address;
116  uint8_t device_status;
117  float press_max;
118  float press_min;
119 
120 } pressure8_t;
121 
125 typedef struct
126 {
127  // Communication gpio pins
128  pin_name_t scl;
129  pin_name_t sda;
130 
131  // Additional gpio pins
132  pin_name_t rst;
133  pin_name_t eoc;
134 
135  // static variable
136  uint32_t i2c_speed;
137  uint8_t i2c_address;
138 
140  // End types group
142 
143 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
144 
150 #ifdef __cplusplus
151 extern "C"{
152 #endif
153 
163 
173 
183 void pressure8_generic_read ( pressure8_t *ctx, uint8_t *data_buf, uint8_t len );
184 
195 float pressure8_get_pressure ( pressure8_t *ctx, uint8_t press_format );
196 
205 
216 
227 
243 void pressure8_set_psi_range ( pressure8_t *ctx, float psi_min, float psi_max );
244 
245 #ifdef __cplusplus
246 }
247 #endif
248 #endif // _PRESSURE8_H_
249  // End public_function group
252 
253 // ------------------------------------------------------------------------- END
pressure8_t::press_min
float press_min
Definition: pressure8.h:118
pressure8_cfg_t::i2c_address
uint8_t i2c_address
Definition: pressure8.h:137
pressure8_t::i2c
i2c_master_t i2c
Definition: pressure8.h:112
pressure8_init
err_t pressure8_init(pressure8_t *ctx, pressure8_cfg_t *cfg)
Initialization function.
pressure8_cfg_t::sda
pin_name_t sda
Definition: pressure8.h:129
pressure8_t
Click ctx object definition.
Definition: pressure8.h:104
pressure8_cfg_t::eoc
pin_name_t eoc
Definition: pressure8.h:133
pressure8_cfg_setup
void pressure8_cfg_setup(pressure8_cfg_t *cfg)
Config Object Initialization function.
pressure8_t::device_status
uint8_t device_status
Definition: pressure8.h:116
pressure8_t::press_max
float press_max
Definition: pressure8.h:117
pressure8_t::slave_address
uint8_t slave_address
Definition: pressure8.h:115
pressure8_t::eoc
digital_in_t eoc
Definition: pressure8.h:109
pressure8_cfg_t::rst
pin_name_t rst
Definition: pressure8.h:132
pressure8_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: pressure8.h:136
pressure8_get_pressure
float pressure8_get_pressure(pressure8_t *ctx, uint8_t press_format)
Functions for get Pressure data.
pressure8_generic_read
void pressure8_generic_read(pressure8_t *ctx, uint8_t *data_buf, uint8_t len)
Generic read function.
pressure8_cfg_t
Click configuration structure definition.
Definition: pressure8.h:126
pressure8_t::rst
digital_out_t rst
Definition: pressure8.h:106
pressure8_cfg_t::scl
pin_name_t scl
Definition: pressure8.h:128
pressure8_get_eoc_state
uint8_t pressure8_get_eoc_state(pressure8_t *ctx)
Functions for get interrupt pin state.
pressure8_device_reset
void pressure8_device_reset(pressure8_t *ctx)
Functions for hardware device reset.
pressure8_get_device_status
uint8_t pressure8_get_device_status(pressure8_t *ctx)
Functions for get device status.
pressure8_set_psi_range
void pressure8_set_psi_range(pressure8_t *ctx, float psi_min, float psi_max)
Functions for set PSI range.