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 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
53 #define PRESSURE8_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
57  cfg.eoc = MIKROBUS( mikrobus, MIKROBUS_INT )
58 
64 #define PRESSURE8_OK 0
65 #define PRESSURE8_ERROR -1
66 
72 #define PRESSURE8_DATA_IN_MBAR 1
73 #define PRESSURE8_DATA_IN_HPA 2
74 #define PRESSURE8_DATA_IN_KPA 3
75 #define PRESSURE8_DATA_IN_TORR 4
76 #define PRESSURE8_DATA_IN_MMHG 5
77  // End group macro
80 // --------------------------------------------------------------- PUBLIC TYPES
89 typedef struct
90 {
91  // Output pins
92  digital_out_t rst;
93 
94  // Input pins
95  digital_in_t eoc;
96 
97  // Modules
98  i2c_master_t i2c;
99 
100  // ctx variable
101  uint8_t slave_address;
102  uint8_t device_status;
103  float press_max;
104  float press_min;
105 
106 } pressure8_t;
107 
111 typedef struct
112 {
113  // Communication gpio pins
114  pin_name_t scl;
115  pin_name_t sda;
116 
117  // Additional gpio pins
118  pin_name_t rst;
119  pin_name_t eoc;
120 
121  // static variable
122  uint32_t i2c_speed;
123  uint8_t i2c_address;
124 
126  // End types group
128 
129 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
130 
136 #ifdef __cplusplus
137 extern "C"{
138 #endif
139 
149 
159 
169 void pressure8_generic_read ( pressure8_t *ctx, uint8_t *data_buf, uint8_t len );
170 
181 float pressure8_get_pressure ( pressure8_t *ctx, uint8_t press_format );
182 
191 
202 
213 
229 void pressure8_set_psi_range ( pressure8_t *ctx, float psi_min, float psi_max );
230 
231 #ifdef __cplusplus
232 }
233 #endif
234 #endif // _PRESSURE8_H_
235  // End public_function group
238 
239 // ------------------------------------------------------------------------- END
pressure8_t::press_min
float press_min
Definition: pressure8.h:104
pressure8_cfg_t::i2c_address
uint8_t i2c_address
Definition: pressure8.h:123
pressure8_t::i2c
i2c_master_t i2c
Definition: pressure8.h:98
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:115
pressure8_t
Click ctx object definition.
Definition: pressure8.h:90
pressure8_cfg_t::eoc
pin_name_t eoc
Definition: pressure8.h:119
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:102
pressure8_t::press_max
float press_max
Definition: pressure8.h:103
pressure8_t::slave_address
uint8_t slave_address
Definition: pressure8.h:101
pressure8_t::eoc
digital_in_t eoc
Definition: pressure8.h:95
pressure8_cfg_t::rst
pin_name_t rst
Definition: pressure8.h:118
pressure8_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: pressure8.h:122
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:112
pressure8_t::rst
digital_out_t rst
Definition: pressure8.h:92
pressure8_cfg_t::scl
pin_name_t scl
Definition: pressure8.h:114
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.