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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 
59 #define ULTRALOWPRESS_REG_CMD 0x22
60 #define ULTRALOWPRESS_REG_TEMP 0x2E
61 #define ULTRALOWPRESS_REG_PRESS 0x30
62 #define ULTRALOWPRESS_REG_STATUS_SYNC 0x32
63 #define ULTRALOWPRESS_REG_STATUS 0x36
64 #define ULTRALOWPRESS_REG_SERIAL_NUM_L 0x50
65 #define ULTRALOWPRESS_REG_SERIAL_NUM_H 0x52
66  // ultralowpress_reg
68 
83 #define ULTRALOWPRESS_REG_CMD_SLEEP 0x6C32
84 #define ULTRALOWPRESS_REG_CMD_RESET 0xB169
85 #define ULTRALOWPRESS_STATUS_CLEAR 0xFFFF
86 
92 #define ULTRALOWPRESS_SET_DEV_ADDR 0x6C
93  // ultralowpress_set
95 
110 #define ULTRALOWPRESS_MAP_MIKROBUS( cfg, mikrobus ) \
111  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
112  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
113  // ultralowpress_map // ultralowpress
116 
121 typedef struct
122 {
123  // Modules
124  i2c_master_t i2c;
126  // I2C slave address
127  uint8_t slave_address;
130 
135 typedef struct
136 {
137  pin_name_t scl;
138  pin_name_t sda;
140  uint32_t i2c_speed;
141  uint8_t i2c_address;
144 
149 typedef enum
150 {
153 
155 
171 
185 
197 err_t ultralowpress_generic_write ( ultralowpress_t *ctx, uint8_t reg, uint16_t tx_data );
198 
210 err_t ultralowpress_generic_read ( ultralowpress_t *ctx, uint8_t reg, uint16_t *rx_data );
211 
220 
230 
239 
248 
249 #ifdef __cplusplus
250 }
251 #endif
252 #endif // ULTRALOWPRESS_H
253  // ultralowpress
255 
256 // ------------------------------------------------------------------------ END
ultralowpress_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: ultralowpress.h:140
ultralowpress_cfg_t
Ultra-Low Press Click configuration object.
Definition: ultralowpress.h:136
ultralowpress_cfg_t::sda
pin_name_t sda
Definition: ultralowpress.h:138
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:141
ultralowpress_cfg_t::scl
pin_name_t scl
Definition: ultralowpress.h:137
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:124
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:150
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:152
ultralowpress_t
Ultra-Low Press Click context object.
Definition: ultralowpress.h:122
ultralowpress_t::slave_address
uint8_t slave_address
Definition: ultralowpress.h:127
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:151
ultralowpress_generic_write
err_t ultralowpress_generic_write(ultralowpress_t *ctx, uint8_t reg, uint16_t tx_data)
Writing function.