manometer2 2.0.0.0
manometer2.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 MANOMETER2_H
36#define MANOMETER2_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#include "drv_spi_master.h"
56
57// -------------------------------------------------------------- PUBLIC MACROS
68#define MANOMETER2_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
70 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
71 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
79#define MANOMETER2_RETVAL uint8_t
80
81#define MANOMETER2_OK 0x00
82#define MANOMETER2_INIT_ERROR 0xFF
89#define MANOMETER2_I2C_ADDRESS_0 0x76
90#define MANOMETER2_I2C_ADDRESS_1 0x77
97#define MANOMETER2_RESET 0x1E
98#define MANOMETER2_RESET_CMD 0xA6
99#define MANOMETER2_ADC_READ 0x00
100#define MANOMETER2_D1_CONVERT_256 0x40
101#define MANOMETER2_D1_CONVERT_512 0x42
102#define MANOMETER2_D1_CONVERT_1024 0x44
103#define MANOMETER2_D1_CONVERT_2048 0x46
104#define MANOMETER2_D1_CONVERT_4096 0x48
105#define MANOMETER2_D2_CONVERT_256 0x50
106#define MANOMETER2_D2_CONVERT_512 0x52
107#define MANOMETER2_D2_CONVERT_1024 0x54
108#define MANOMETER2_D2_CONVERT_2048 0x56
109#define MANOMETER2_D2_CONVERT_4096 0x58
110#define MANOMETER2_C1_READ 0xA2
111#define MANOMETER2_C2_READ 0xA4
112#define MANOMETER2_C3_READ 0xA6
113#define MANOMETER2_C4_READ 0xA8
114#define MANOMETER2_C5_READ 0xAA
115#define MANOMETER2_C6_READ 0xAC
116#define MANOMETER2_CONVERT_256 0
117#define MANOMETER2_CONVERT_512 1
118#define MANOMETER2_CONVERT_1024 2
119#define MANOMETER2_CONVERT_2048 3
120#define MANOMETER2_CONVERT_4096 4
127#define MANOMETER2_Q1 14
128#define MANOMETER2_Q2 16
129#define MANOMETER2_Q3 7
130#define MANOMETER2_Q4 5
131#define MANOMETER2_Q5 7
132#define MANOMETER2_Q6 21
135 // End group macro
136// --------------------------------------------------------------- PUBLIC TYPES
143typedef struct
144{
145 uint16_t coef1;
146 uint16_t coef2;
147 uint16_t coef3;
148 uint16_t coef4;
149 uint16_t coef5;
150 uint16_t coef6;
151
153
157typedef struct manometer2_s
158{
159 // Output pins
160
161 digital_out_t cs;
162
163 // Modules
164
165 i2c_master_t i2c;
166 spi_master_t spi;
167
168 // ctx variable
169
171
173
175
179typedef struct
180{
181 // Communication gpio pins
182
183 pin_name_t scl;
184 pin_name_t sda;
185 pin_name_t cs;
186
187 // static variable
188
189 uint32_t i2c_speed;
190 uint8_t i2c_address;
191
193
194 // End types group
195// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
201#ifdef __cplusplus
202extern "C"{
203#endif
204
214
224
233
243void manometer2_write_data ( manometer2_t *ctx, uint8_t reg_address, uint8_t write_command );
244
256uint16_t manometer2_read_data ( manometer2_t *ctx, uint8_t reg_address );
257
269uint32_t manometer2_read_command ( manometer2_t *ctx, uint8_t reg_address );
270
279
288
300float manometer2_get_temperature ( manometer2_t *ctx, uint8_t oversampling_ratio );
301
313float manometer2_get_pressure ( manometer2_t *ctx, uint8_t oversampling_ratio );
314
315#ifdef __cplusplus
316}
317#endif
318#endif // _MANOMETER2_H_
319
320 // End public_function group
322
323// ------------------------------------------------------------------------- END
#define MANOMETER2_RETVAL
Definition manometer2.h:79
MANOMETER2_RETVAL manometer2_init(manometer2_t *ctx, manometer2_cfg_t *cfg)
Initialization function.
void manometer2_cfg_setup(manometer2_cfg_t *cfg)
Config Object Initialization function.
float manometer2_get_temperature(manometer2_t *ctx, uint8_t oversampling_ratio)
Get temperature data function.
uint16_t manometer2_read_data(manometer2_t *ctx, uint8_t reg_address)
Generic read data function.
void manometer2_write_data(manometer2_t *ctx, uint8_t reg_address, uint8_t write_command)
Generic write data function.
void manometer2_read_coef(manometer2_t *ctx)
Function read coeffitient.
uint32_t manometer2_read_command(manometer2_t *ctx, uint8_t reg_address)
Generic read data function.
void manometer2_default_cfg(manometer2_t *ctx)
Click Default Configuration function.
void manometer2_reset(manometer2_t *ctx)
Reset.
float manometer2_get_pressure(manometer2_t *ctx, uint8_t oversampling_ratio)
Get pressure data function.
struct manometer2_s manometer2_t
Click ctx object definition.
Click configuration structure definition.
Definition manometer2.h:180
uint32_t i2c_speed
Definition manometer2.h:189
pin_name_t scl
Definition manometer2.h:183
pin_name_t sda
Definition manometer2.h:184
pin_name_t cs
Definition manometer2.h:185
uint8_t i2c_address
Definition manometer2.h:190
Definition manometer2.h:144
uint16_t coef4
Definition manometer2.h:148
uint16_t coef6
Definition manometer2.h:150
uint16_t coef2
Definition manometer2.h:146
uint16_t coef5
Definition manometer2.h:149
uint16_t coef3
Definition manometer2.h:147
uint16_t coef1
Definition manometer2.h:145
Click ctx object definition.
Definition manometer2.h:158
digital_out_t cs
Definition manometer2.h:161
spi_master_t spi
Definition manometer2.h:166
manometer2_coef_t coef
Definition manometer2.h:172
i2c_master_t i2c
Definition manometer2.h:165
uint8_t slave_address
Definition manometer2.h:170