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
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
73#define ULTRALOWPRESS_REG_CMD 0x22
74#define ULTRALOWPRESS_REG_TEMP 0x2E
75#define ULTRALOWPRESS_REG_PRESS 0x30
76#define ULTRALOWPRESS_REG_STATUS_SYNC 0x32
77#define ULTRALOWPRESS_REG_STATUS 0x36
78#define ULTRALOWPRESS_REG_SERIAL_NUM_L 0x50
79#define ULTRALOWPRESS_REG_SERIAL_NUM_H 0x52
80
81 // ultralowpress_reg
82
97#define ULTRALOWPRESS_REG_CMD_SLEEP 0x6C32
98#define ULTRALOWPRESS_REG_CMD_RESET 0xB169
99#define ULTRALOWPRESS_STATUS_CLEAR 0xFFFF
100
106#define ULTRALOWPRESS_SET_DEV_ADDR 0x6C
107
108 // ultralowpress_set
109
124#define ULTRALOWPRESS_MAP_MIKROBUS( cfg, mikrobus ) \
125 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
126 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
127
128 // ultralowpress_map
129 // ultralowpress
130
135typedef struct
136{
137 // Modules
138 i2c_master_t i2c;
140 // I2C slave address
144
149typedef struct
150{
151 pin_name_t scl;
152 pin_name_t sda;
154 uint32_t i2c_speed;
155 uint8_t i2c_address;
158
169
185
199
211err_t ultralowpress_generic_write ( ultralowpress_t *ctx, uint8_t reg, uint16_t tx_data );
212
224err_t ultralowpress_generic_read ( ultralowpress_t *ctx, uint8_t reg, uint16_t *rx_data );
225
234
244
253
262
263#ifdef __cplusplus
264}
265#endif
266#endif // ULTRALOWPRESS_H
267
268 // ultralowpress
269
270// ------------------------------------------------------------------------ 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:150
uint32_t i2c_speed
Definition ultralowpress.h:154
pin_name_t scl
Definition ultralowpress.h:151
pin_name_t sda
Definition ultralowpress.h:152
uint8_t i2c_address
Definition ultralowpress.h:155
Ultra-Low Press Click context object.
Definition ultralowpress.h:136
i2c_master_t i2c
Definition ultralowpress.h:138
uint8_t slave_address
Definition ultralowpress.h:141
ultralowpress_return_value_t
Ultra-Low Press Click return value data.
Definition ultralowpress.h:164
@ ULTRALOWPRESS_ERROR
Definition ultralowpress.h:166
@ ULTRALOWPRESS_OK
Definition ultralowpress.h:165