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
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define PRESSURE7_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
69
76#define PRESSURE7_RETVAL uint8_t
77
78#define PRESSURE7_OK 0x00
79#define PRESSURE7_INIT_ERROR 0xFF
86#define PRESSURE7_CMD_RESET 0x1E
87#define PRESSURE7_CMD_CONVERT_D1_OSR_256 0x40
88#define PRESSURE7_CMD_CONVERT_D1_OSR_512 0x42
89#define PRESSURE7_CMD_CONVERT_D1_OSR_1024 0x44
90#define PRESSURE7_CMD_CONVERT_D1_OSR_2048 0x46
91#define PRESSURE7_CMD_CONVERT_D1_OSR_4096 0x48
92#define PRESSURE7_CMD_CONVERT_D1_OSR_8192 0x4A
93#define PRESSURE7_CMD_CONVERT_D2_OSR_256 0x50
94#define PRESSURE7_CMD_CONVERT_D2_OSR_512 0x52
95#define PRESSURE7_CMD_CONVERT_D2_OSR_1024 0x54
96#define PRESSURE7_CMD_CONVERT_D2_OSR_2048 0x56
97#define PRESSURE7_CMD_CONVERT_D2_OSR_4096 0x58
98#define PRESSURE7_CMD_CONVERT_D2_OSR_8912 0x5A
99#define PRESSURE7_CMD_ADC_READ 0x00
100#define PRESSURE7_CMD_PROM_READ 0xA0
107#define PRESSURE7_PROM_ADDR_CRC 0x00
108#define PRESSURE7_PROM_ADDR_C1 0x01 << 1
109#define PRESSURE7_PROM_ADDR_C2 0x02 << 1
110#define PRESSURE7_PROM_ADDR_C3 0x03 << 1
111#define PRESSURE7_PROM_ADDR_C4 0x04 << 1
112#define PRESSURE7_PROM_ADDR_C5 0x05 << 1
113#define PRESSURE7_PROM_ADDR_C6 0x06 << 1
114#define PRESSURE7_PROM_ADDR_C7 0x07 << 1
121#define PRESSURE7_PROM_READ_ERROR 1
122#define PRESSURE7_PROM_READ_OK 0
129#define PRESSURE7_DEVICE_SLAVE_ADDRESS 0x76
132 // End group macro
133// --------------------------------------------------------------- PUBLIC TYPES
142typedef struct
143{
144 // Modules
145
146 i2c_master_t i2c;
147
148 // ctx variable
149
151
152 // additional ctx variables
153
155 float pressure;
156
158
162typedef struct
163{
164 // Communication gpio pins
165
166 pin_name_t scl;
167 pin_name_t sda;
168
169 // static variable
170
171 uint32_t i2c_speed;
172 uint8_t i2c_address;
173
175 // End types group
176
177// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
183#ifdef __cplusplus
184extern "C"{
185#endif
186
196
206
215
237void pressure7_generic_read ( pressure7_t *ctx, uint8_t reg_addr, uint8_t *data_buf, uint8_t len );
238
247void pressure7_send_command ( pressure7_t *ctx, uint8_t cmd );
248
257
270
286
297void pressure7_get_sensor_data ( pressure7_t *ctx, float *Temperature, float *Pressure );
298
311void pressure7_set_over_sampling_ratio ( uint8_t osr_d1, uint8_t osr_d2 );
312
313#ifdef __cplusplus
314}
315#endif
316#endif // _PRESSURE7_H_
317
318 // End public_function group
320
321// ------------------------------------------------------------------------- END
#define PRESSURE7_RETVAL
Definition pressure7.h:76
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:163
uint32_t i2c_speed
Definition pressure7.h:171
pin_name_t scl
Definition pressure7.h:166
pin_name_t sda
Definition pressure7.h:167
uint8_t i2c_address
Definition pressure7.h:172
Click ctx object definition.
Definition pressure7.h:143
i2c_master_t i2c
Definition pressure7.h:146
float pressure
Definition pressure7.h:155
uint8_t slave_address
Definition pressure7.h:150
float temperature
Definition pressure7.h:154