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
32extern "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
121typedef struct
122{
123 // Modules
124 i2c_master_t i2c;
126 // I2C slave address
130
135typedef struct
136{
137 pin_name_t scl;
138 pin_name_t sda;
140 uint32_t i2c_speed;
141 uint8_t i2c_address;
144
149typedef enum
150{
153
155
171
186
199err_t ultralowpress_generic_write ( ultralowpress_t *ctx, uint8_t reg, uint16_t tx_data );
200
213err_t ultralowpress_generic_read ( ultralowpress_t *ctx, uint8_t reg, uint16_t *rx_data );
214
223
233
242
251
252#ifdef __cplusplus
253}
254#endif
255#endif // ULTRALOWPRESS_H
256 // ultralowpress
258
259// ------------------------------------------------------------------------ END
float ultralowpress_get_press(ultralowpress_t *ctx)
Read pressure.
err_t ultralowpress_generic_read(ultralowpress_t *ctx, uint8_t reg, uint16_t *rx_data)
Reading function.
err_t ultralowpress_init(ultralowpress_t *ctx, ultralowpress_cfg_t *cfg)
Ultra-Low Press initialization function.
void ultralowpress_cfg_setup(ultralowpress_cfg_t *cfg)
Ultra-Low Press configuration object setup function.
uint8_t ultralowpress_ready_to_read(ultralowpress_t *ctx)
Ready to read.
err_t ultralowpress_generic_write(ultralowpress_t *ctx, uint8_t reg, uint16_t tx_data)
Writing function.
float ultralowpress_get_temp(ultralowpress_t *ctx)
Read temperature.
void ultralowpress_clear_status(ultralowpress_t *ctx)
Clear status.
Ultra-Low Press Click configuration object.
Definition: ultralowpress.h:136
uint32_t i2c_speed
Definition: ultralowpress.h:140
pin_name_t scl
Definition: ultralowpress.h:137
pin_name_t sda
Definition: ultralowpress.h:138
uint8_t i2c_address
Definition: ultralowpress.h:141
Ultra-Low Press Click context object.
Definition: ultralowpress.h:122
i2c_master_t i2c
Definition: ultralowpress.h:124
uint8_t slave_address
Definition: ultralowpress.h:127
ultralowpress_return_value_t
Ultra-Low Press Click return value data.
Definition: ultralowpress.h:150
@ ULTRALOWPRESS_ERROR
Definition: ultralowpress.h:152
@ ULTRALOWPRESS_OK
Definition: ultralowpress.h:151