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 "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_digital_in.h"
50 #include "drv_i2c_master.h"
51 
52 
53 // -------------------------------------------------------------- PUBLIC MACROS
63 #define PRESSURE8_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
65  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
66  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
67  cfg.eoc = MIKROBUS( mikrobus, MIKROBUS_INT )
68 
74 #define PRESSURE8_OK 0
75 #define PRESSURE8_ERROR -1
76 
82 #define PRESSURE8_DATA_IN_MBAR 1
83 #define PRESSURE8_DATA_IN_HPA 2
84 #define PRESSURE8_DATA_IN_KPA 3
85 #define PRESSURE8_DATA_IN_TORR 4
86 #define PRESSURE8_DATA_IN_MMHG 5
87  // End group macro
90 // --------------------------------------------------------------- PUBLIC TYPES
99 typedef struct
100 {
101  // Output pins
102  digital_out_t rst;
103 
104  // Input pins
105  digital_in_t eoc;
106 
107  // Modules
108  i2c_master_t i2c;
109 
110  // ctx variable
111  uint8_t slave_address;
112  uint8_t device_status;
113  float press_max;
114  float press_min;
115 
116 } pressure8_t;
117 
121 typedef struct
122 {
123  // Communication gpio pins
124  pin_name_t scl;
125  pin_name_t sda;
126 
127  // Additional gpio pins
128  pin_name_t rst;
129  pin_name_t eoc;
130 
131  // static variable
132  uint32_t i2c_speed;
133  uint8_t i2c_address;
134 
136  // End types group
138 
139 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
140 
146 #ifdef __cplusplus
147 extern "C"{
148 #endif
149 
159 
169 
179 void pressure8_generic_read ( pressure8_t *ctx, uint8_t *data_buf, uint8_t len );
180 
191 float pressure8_get_pressure ( pressure8_t *ctx, uint8_t press_format );
192 
201 
212 
223 
239 void pressure8_set_psi_range ( pressure8_t *ctx, float psi_min, float psi_max );
240 
241 #ifdef __cplusplus
242 }
243 #endif
244 #endif // _PRESSURE8_H_
245  // End public_function group
248 
249 // ------------------------------------------------------------------------- END
pressure8_t::press_min
float press_min
Definition: pressure8.h:114
pressure8_cfg_t::i2c_address
uint8_t i2c_address
Definition: pressure8.h:133
pressure8_t::i2c
i2c_master_t i2c
Definition: pressure8.h:108
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:125
pressure8_t
Click ctx object definition.
Definition: pressure8.h:100
pressure8_cfg_t::eoc
pin_name_t eoc
Definition: pressure8.h:129
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:112
pressure8_t::press_max
float press_max
Definition: pressure8.h:113
pressure8_t::slave_address
uint8_t slave_address
Definition: pressure8.h:111
pressure8_t::eoc
digital_in_t eoc
Definition: pressure8.h:105
pressure8_cfg_t::rst
pin_name_t rst
Definition: pressure8.h:128
pressure8_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: pressure8.h:132
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:122
pressure8_t::rst
digital_out_t rst
Definition: pressure8.h:102
pressure8_cfg_t::scl
pin_name_t scl
Definition: pressure8.h:124
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.