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 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
52 #define HYDROPROBE_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
55 
61 #define HYDROPROBE_RETVAL uint8_t
62 
63 #define HYDROPROBE_OK 0x00
64 #define HYDROPROBE_INIT_ERROR 0xFF
65 
71 #define HYDROPROBE_SLAVE_ADR 0x4D
72  // End group macro
75 // --------------------------------------------------------------- PUBLIC TYPES
84 typedef struct
85 {
86  // Modules
87 
88  i2c_master_t i2c;
89 
90  // ctx variable
91 
92  uint8_t slave_address;
93 
94 } hydroprobe_t;
95 
99 typedef struct
100 {
101  // Communication gpio pins
102 
103  pin_name_t scl;
104  pin_name_t sda;
105 
106  // static variable
107 
108  uint32_t i2c_speed;
109  uint8_t i2c_address;
110 
112  // End types group
114 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
115 
121 #ifdef __cplusplus
122 extern "C"{
123 #endif
124 
134 
144 
155 void hydroprobe_generic_write ( hydroprobe_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
156 
167 void hydroprobe_generic_read ( hydroprobe_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
168 
179 
190 
201 
212 
224 uint8_t hydroprobe_rel_env_hum ( hydroprobe_t *ctx, uint16_t dry_val, uint16_t wet_val );
225 
226 #ifdef __cplusplus
227 }
228 #endif
229 #endif // _HYDROPROBE_H_
230  // End public_function group
233 
234 // ------------------------------------------------------------------------- END
hydroprobe_cfg_t
Click configuration structure definition.
Definition: hydroprobe.h:100
hydroprobe_t::slave_address
uint8_t slave_address
Definition: hydroprobe.h:92
hydroprobe_cfg_t::i2c_address
uint8_t i2c_address
Definition: hydroprobe.h:109
hydroprobe_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: hydroprobe.h:108
hydroprobe_generic_read
void hydroprobe_generic_read(hydroprobe_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
hydroprobe_cfg_t::sda
pin_name_t sda
Definition: hydroprobe.h:104
HYDROPROBE_RETVAL
#define HYDROPROBE_RETVAL
Definition: hydroprobe.h:61
hydroprobe_t
Click ctx object definition.
Definition: hydroprobe.h:85
hydroprobe_init
HYDROPROBE_RETVAL hydroprobe_init(hydroprobe_t *ctx, hydroprobe_cfg_t *cfg)
Initialization function.
hydroprobe_cfg_t::scl
pin_name_t scl
Definition: hydroprobe.h:103
hydroprobe_min_val
uint16_t hydroprobe_min_val(hydroprobe_t *ctx)
Get minimum value function.
hydroprobe_read_raw
uint16_t hydroprobe_read_raw(hydroprobe_t *ctx)
Read raw data function.
hydroprobe_cfg_setup
void hydroprobe_cfg_setup(hydroprobe_cfg_t *cfg)
Config Object Initialization function.
hydroprobe_max_val
uint16_t hydroprobe_max_val(hydroprobe_t *ctx)
Get maximum value function.
hydroprobe_avg_val
uint16_t hydroprobe_avg_val(hydroprobe_t *ctx)
Get average value function.
hydroprobe_t::i2c
i2c_master_t i2c
Definition: hydroprobe.h:88
hydroprobe_rel_env_hum
uint8_t hydroprobe_rel_env_hum(hydroprobe_t *ctx, uint16_t dry_val, uint16_t wet_val)
Get Relative humidity of the environment function.
hydroprobe_generic_write
void hydroprobe_generic_write(hydroprobe_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.