pressure6 2.0.0.0
pressure6.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 PRESSURE6_H
36#define PRESSURE6_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
57
62#define PRESSURE6_MAP_MIKROBUS( cfg, mikrobus ) \
63 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
64 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
65 cfg.dri = MIKROBUS( mikrobus, MIKROBUS_INT )
71#define PRESSURE6_RETVAL uint8_t
72
73#define PRESSURE6_OK 0x00
74#define PRESSURE6_INIT_ERROR 0xFF
80#define PRESSURE6_MC_AVE_NUM_SINGLE 0x00
81#define PRESSURE6_MC_AVE_NUM_2_TIMES 0x20
82#define PRESSURE6_MC_AVE_NUM_4_TIMES 0x40
83#define PRESSURE6_MC_AVE_NUM_8_TIMES 0x60
84#define PRESSURE6_MC_AVE_NUM_16_TIMES 0x80
85#define PRESSURE6_MC_AVE_NUM_32_TIMES 0xA0
86#define PRESSURE6_MC_AVE_NUM_64_TIMES 0xC0
87#define PRESSURE6_MC_AVE_NUM_PROHIBITED 0xE0
88#define PRESSURE6_MC_DATA_READY_ENABLED 0x10
89#define PRESSURE6_MC_DATA_READY_DISABLED 0x00
90#define PRESSURE6_MC_FULL_DATA_ENABLED 0x08
91#define PRESSURE6_MC_FULL_DATA_DISABLED 0x00
92#define PRESSURE6_MC_WATER_MARK_ENABLED 0x04
93#define PRESSURE6_MC_WATER_MARK_DISABLED 0x00
94#define PRESSURE6_MC_MODE_STAND_BY 0x00
95#define PRESSURE6_MC_MODE_ONE_SHOT 0x01
96#define PRESSURE6_MC_MODE_CONTINUOUS 0x02
97#define PRESSURE6_REG_MODE_CONTROL 0x14
99 // End group macro
100// --------------------------------------------------------------- PUBLIC TYPES
109typedef struct
110{
111 // Input pins
112
113 digital_in_t dri;
114
115 // Modules
116
117 i2c_master_t i2c;
118
119 // ctx variable
120
122
124
128typedef struct
129{
130 // Communication gpio pins
131
132 pin_name_t scl;
133 pin_name_t sda;
134
135 // Additional gpio pins
136
137 pin_name_t dri;
138
139 // static variable
140
141 uint32_t i2c_speed;
142 uint8_t i2c_address;
143
145
146 // End types group
147// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
148
154#ifdef __cplusplus
155extern "C"{
156#endif
157
167
177
191
201void pressure6_write_byte( pressure6_t *ctx, uint8_t reg, uint8_t data_in );
202
213uint8_t pressure6_read_byte( pressure6_t *ctx, uint8_t reg);
214
225
236
247
258
267
276
285
286#ifdef __cplusplus
287}
288#endif
289#endif // _PRESSURE6_H_
290
291 // End public_function group
293
294// ------------------------------------------------------------------------- END
#define PRESSURE6_RETVAL
Definition pressure6.h:71
uint16_t pressure6_get_pressure(pressure6_t *ctx)
Pressure value.
PRESSURE6_RETVAL pressure6_init(pressure6_t *ctx, pressure6_cfg_t *cfg)
Initialization function.
uint8_t pressure6_get_temperature(pressure6_t *ctx)
Temperature value.
void pressure6_waiting_for_new_data(pressure6_t *ctx)
Waits for new data.
void pressure6_cfg_setup(pressure6_cfg_t *cfg)
Config Object Initialization function.
void pressure6_default_cfg(pressure6_t *ctx)
Click Default Configuration function.
void pressure6_power_on(pressure6_t *ctx)
Power ON.
void pressure6_power_off(pressure6_t *ctx)
Power OFF.
uint8_t pressure6_get_interrupt(pressure6_t *ctx)
Interupt.
uint8_t pressure6_read_byte(pressure6_t *ctx, uint8_t reg)
Byte read function.
void pressure6_write_byte(pressure6_t *ctx, uint8_t reg, uint8_t data_in)
Byte write function.
uint8_t pressure6_get_status(pressure6_t *ctx)
Status.
Click configuration structure definition.
Definition pressure6.h:129
uint32_t i2c_speed
Definition pressure6.h:141
pin_name_t scl
Definition pressure6.h:132
pin_name_t dri
Definition pressure6.h:137
pin_name_t sda
Definition pressure6.h:133
uint8_t i2c_address
Definition pressure6.h:142
Click ctx object definition.
Definition pressure6.h:110
i2c_master_t i2c
Definition pressure6.h:117
uint8_t slave_address
Definition pressure6.h:121
digital_in_t dri
Definition pressure6.h:113