ultralowpress  2.0.0.0
ultralowpress.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef ULTRALOWPRESS_H
29 #define ULTRALOWPRESS_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define ULTRALOWPRESS_REG_CMD 0x22
70 #define ULTRALOWPRESS_REG_TEMP 0x2E
71 #define ULTRALOWPRESS_REG_PRESS 0x30
72 #define ULTRALOWPRESS_REG_STATUS_SYNC 0x32
73 #define ULTRALOWPRESS_REG_STATUS 0x36
74 #define ULTRALOWPRESS_REG_SERIAL_NUM_L 0x50
75 #define ULTRALOWPRESS_REG_SERIAL_NUM_H 0x52
76  // ultralowpress_reg
78 
93 #define ULTRALOWPRESS_REG_CMD_SLEEP 0x6C32
94 #define ULTRALOWPRESS_REG_CMD_RESET 0xB169
95 #define ULTRALOWPRESS_STATUS_CLEAR 0xFFFF
96 
102 #define ULTRALOWPRESS_SET_DEV_ADDR 0x6C
103  // ultralowpress_set
105 
120 #define ULTRALOWPRESS_MAP_MIKROBUS( cfg, mikrobus ) \
121  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
122  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
123  // ultralowpress_map // ultralowpress
126 
131 typedef struct
132 {
133  // Modules
134  i2c_master_t i2c;
136  // I2C slave address
137  uint8_t slave_address;
140 
145 typedef struct
146 {
147  pin_name_t scl;
148  pin_name_t sda;
150  uint32_t i2c_speed;
151  uint8_t i2c_address;
154 
159 typedef enum
160 {
163 
165 
181 
195 
207 err_t ultralowpress_generic_write ( ultralowpress_t *ctx, uint8_t reg, uint16_t tx_data );
208 
220 err_t ultralowpress_generic_read ( ultralowpress_t *ctx, uint8_t reg, uint16_t *rx_data );
221 
230 
240 
249 
258 
259 #ifdef __cplusplus
260 }
261 #endif
262 #endif // ULTRALOWPRESS_H
263  // ultralowpress
265 
266 // ------------------------------------------------------------------------ END
ultralowpress_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: ultralowpress.h:150
ultralowpress_cfg_t
Ultra-Low Press Click configuration object.
Definition: ultralowpress.h:146
ultralowpress_cfg_t::sda
pin_name_t sda
Definition: ultralowpress.h:148
ultralowpress_clear_status
void ultralowpress_clear_status(ultralowpress_t *ctx)
Clear status.
ultralowpress_ready_to_read
uint8_t ultralowpress_ready_to_read(ultralowpress_t *ctx)
Ready to read.
ultralowpress_cfg_t::i2c_address
uint8_t i2c_address
Definition: ultralowpress.h:151
ultralowpress_cfg_t::scl
pin_name_t scl
Definition: ultralowpress.h:147
ultralowpress_get_press
float ultralowpress_get_press(ultralowpress_t *ctx)
Read pressure.
ultralowpress_cfg_setup
void ultralowpress_cfg_setup(ultralowpress_cfg_t *cfg)
Ultra-Low Press configuration object setup function.
ultralowpress_t::i2c
i2c_master_t i2c
Definition: ultralowpress.h:134
ultralowpress_get_temp
float ultralowpress_get_temp(ultralowpress_t *ctx)
Read temperature.
ultralowpress_return_value_t
ultralowpress_return_value_t
Ultra-Low Press Click return value data.
Definition: ultralowpress.h:160
ultralowpress_generic_read
err_t ultralowpress_generic_read(ultralowpress_t *ctx, uint8_t reg, uint16_t *rx_data)
Reading function.
ULTRALOWPRESS_ERROR
@ ULTRALOWPRESS_ERROR
Definition: ultralowpress.h:162
ultralowpress_t
Ultra-Low Press Click context object.
Definition: ultralowpress.h:132
ultralowpress_t::slave_address
uint8_t slave_address
Definition: ultralowpress.h:137
ultralowpress_init
err_t ultralowpress_init(ultralowpress_t *ctx, ultralowpress_cfg_t *cfg)
Ultra-Low Press initialization function.
ULTRALOWPRESS_OK
@ ULTRALOWPRESS_OK
Definition: ultralowpress.h:161
ultralowpress_generic_write
err_t ultralowpress_generic_write(ultralowpress_t *ctx, uint8_t reg, uint16_t tx_data)
Writing function.