hydroprobe 2.0.0.0
hydroprobe.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 HYDROPROBE_H
36#define HYDROPROBE_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 HYDROPROBE_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
75#define HYDROPROBE_RETVAL uint8_t
76
77#define HYDROPROBE_OK 0x00
78#define HYDROPROBE_INIT_ERROR 0xFF
85#define HYDROPROBE_SLAVE_ADR 0x4D
88 // End group macro
89// --------------------------------------------------------------- PUBLIC TYPES
98typedef struct
99{
100 // Modules
101
102 i2c_master_t i2c;
103
104 // ctx variable
105
107
109
113typedef struct
114{
115 // Communication gpio pins
116
117 pin_name_t scl;
118 pin_name_t sda;
119
120 // static variable
121
122 uint32_t i2c_speed;
123 uint8_t i2c_address;
124
126
127 // End types group
128// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
129
135#ifdef __cplusplus
136extern "C"{
137#endif
138
148
158
169void hydroprobe_generic_write ( hydroprobe_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
170
181void hydroprobe_generic_read ( hydroprobe_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
182
193
204
215
226
238uint8_t hydroprobe_rel_env_hum ( hydroprobe_t *ctx, uint16_t dry_val, uint16_t wet_val );
239
240#ifdef __cplusplus
241}
242#endif
243#endif // _HYDROPROBE_H_
244
245 // End public_function group
247
248// ------------------------------------------------------------------------- END
#define HYDROPROBE_RETVAL
Definition hydroprobe.h:75
uint16_t hydroprobe_max_val(hydroprobe_t *ctx)
Get maximum value function.
void hydroprobe_generic_read(hydroprobe_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint16_t hydroprobe_read_raw(hydroprobe_t *ctx)
Read raw data function.
void hydroprobe_cfg_setup(hydroprobe_cfg_t *cfg)
Config Object Initialization function.
HYDROPROBE_RETVAL hydroprobe_init(hydroprobe_t *ctx, hydroprobe_cfg_t *cfg)
Initialization function.
uint16_t hydroprobe_avg_val(hydroprobe_t *ctx)
Get average value function.
void hydroprobe_generic_write(hydroprobe_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint16_t hydroprobe_min_val(hydroprobe_t *ctx)
Get minimum value function.
uint8_t hydroprobe_rel_env_hum(hydroprobe_t *ctx, uint16_t dry_val, uint16_t wet_val)
Get Relative humidity of the environment function.
Click configuration structure definition.
Definition hydroprobe.h:114
uint32_t i2c_speed
Definition hydroprobe.h:122
pin_name_t scl
Definition hydroprobe.h:117
pin_name_t sda
Definition hydroprobe.h:118
uint8_t i2c_address
Definition hydroprobe.h:123
Click ctx object definition.
Definition hydroprobe.h:99
i2c_master_t i2c
Definition hydroprobe.h:102
uint8_t slave_address
Definition hydroprobe.h:106