pressure7 2.0.0.0
pressure7.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 PRESSURE7_H
36#define PRESSURE7_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40#include "drv_i2c_master.h"
41
42// -------------------------------------------------------------- PUBLIC MACROS
52#define PRESSURE7_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
55
62#define PRESSURE7_RETVAL uint8_t
63
64#define PRESSURE7_OK 0x00
65#define PRESSURE7_INIT_ERROR 0xFF
72#define PRESSURE7_CMD_RESET 0x1E
73#define PRESSURE7_CMD_CONVERT_D1_OSR_256 0x40
74#define PRESSURE7_CMD_CONVERT_D1_OSR_512 0x42
75#define PRESSURE7_CMD_CONVERT_D1_OSR_1024 0x44
76#define PRESSURE7_CMD_CONVERT_D1_OSR_2048 0x46
77#define PRESSURE7_CMD_CONVERT_D1_OSR_4096 0x48
78#define PRESSURE7_CMD_CONVERT_D1_OSR_8192 0x4A
79#define PRESSURE7_CMD_CONVERT_D2_OSR_256 0x50
80#define PRESSURE7_CMD_CONVERT_D2_OSR_512 0x52
81#define PRESSURE7_CMD_CONVERT_D2_OSR_1024 0x54
82#define PRESSURE7_CMD_CONVERT_D2_OSR_2048 0x56
83#define PRESSURE7_CMD_CONVERT_D2_OSR_4096 0x58
84#define PRESSURE7_CMD_CONVERT_D2_OSR_8912 0x5A
85#define PRESSURE7_CMD_ADC_READ 0x00
86#define PRESSURE7_CMD_PROM_READ 0xA0
93#define PRESSURE7_PROM_ADDR_CRC 0x00
94#define PRESSURE7_PROM_ADDR_C1 0x01 << 1
95#define PRESSURE7_PROM_ADDR_C2 0x02 << 1
96#define PRESSURE7_PROM_ADDR_C3 0x03 << 1
97#define PRESSURE7_PROM_ADDR_C4 0x04 << 1
98#define PRESSURE7_PROM_ADDR_C5 0x05 << 1
99#define PRESSURE7_PROM_ADDR_C6 0x06 << 1
100#define PRESSURE7_PROM_ADDR_C7 0x07 << 1
107#define PRESSURE7_PROM_READ_ERROR 1
108#define PRESSURE7_PROM_READ_OK 0
115#define PRESSURE7_DEVICE_SLAVE_ADDRESS 0x76 // End group macro
119// --------------------------------------------------------------- PUBLIC TYPES
128typedef struct
129{
130 // Modules
131
132 i2c_master_t i2c;
133
134 // ctx variable
135
137
138 // additional ctx variables
139
141 float pressure;
142
144
148typedef struct
149{
150 // Communication gpio pins
151
152 pin_name_t scl;
153 pin_name_t sda;
154
155 // static variable
156
157 uint32_t i2c_speed;
158 uint8_t i2c_address;
159
160} pressure7_cfg_t; // End types group
162
163// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
169#ifdef __cplusplus
170extern "C"{
171#endif
172
182
192
201
223void pressure7_generic_read ( pressure7_t *ctx, uint8_t reg_addr, uint8_t *data_buf, uint8_t len );
224
233void pressure7_send_command ( pressure7_t *ctx, uint8_t cmd );
234
243
256
272
283void pressure7_get_sensor_data ( pressure7_t *ctx, float *Temperature, float *Pressure );
284
297void pressure7_set_over_sampling_ratio ( uint8_t osr_d1, uint8_t osr_d2 );
298
299#ifdef __cplusplus
300}
301#endif
302#endif // _PRESSURE7_H_
303 // End public_function group
306
307// ------------------------------------------------------------------------- END
#define PRESSURE7_RETVAL
Definition: pressure7.h:62
void pressure7_start_measurement(pressure7_t *ctx)
Start measurement and calculation data.
void pressure7_cfg_setup(pressure7_cfg_t *cfg)
Config Object Initialization function.
void pressure7_reset(pressure7_t *ctx)
Start reset sequence.
void pressure7_generic_read(pressure7_t *ctx, uint8_t reg_addr, uint8_t *data_buf, uint8_t len)
Generic read function.
void pressure7_get_sensor_data(pressure7_t *ctx, float *Temperature, float *Pressure)
Read Pressure and Temperature data.
void pressure7_default_cfg(pressure7_t *ctx)
Click Default Configuration function.
uint8_t pressure7_read_prom(pressure7_t *ctx)
Read calibration data from PROM.
void pressure7_set_over_sampling_ratio(uint8_t osr_d1, uint8_t osr_d2)
Set OSR(Over sampling ratio) for Pressure(D1) and Temperature(D2) data.
PRESSURE7_RETVAL pressure7_init(pressure7_t *ctx, pressure7_cfg_t *cfg)
Initialization function.
void pressure7_send_command(pressure7_t *ctx, uint8_t cmd)
Send command to click.
Click configuration structure definition.
Definition: pressure7.h:149
uint32_t i2c_speed
Definition: pressure7.h:157
pin_name_t scl
Definition: pressure7.h:152
pin_name_t sda
Definition: pressure7.h:153
uint8_t i2c_address
Definition: pressure7.h:158
Click ctx object definition.
Definition: pressure7.h:129
i2c_master_t i2c
Definition: pressure7.h:132
float pressure
Definition: pressure7.h:141
uint8_t slave_address
Definition: pressure7.h:136
float temperature
Definition: pressure7.h:140