turbidity 2.0.0.0
turbidity.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef TURBIDITY_H
29#define TURBIDITY_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
79#define TURBIDITY_SET_DEV_ADDR 0x4D
80
81 // turbidity_set
82
97#define TURBIDITY_MAP_MIKROBUS( cfg, mikrobus ) \
98 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
99 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
100
101 // turbidity_map
102 // turbidity
103
108typedef struct
109{
110 // Modules
111 i2c_master_t i2c;
113 // I2C slave address
117
122typedef struct
123{
124 pin_name_t scl;
125 pin_name_t sda;
127 uint32_t i2c_speed;
128 uint8_t i2c_address;
131
142
159
175
190
205err_t turbidity_generic_read ( turbidity_t *ctx, uint8_t *rx_buf, uint8_t rx_len );
206
220err_t turbidity_read_adc ( turbidity_t *ctx, uint16_t *adc_val );
221
235err_t turbidity_get_adc_voltage ( turbidity_t *ctx, float *voltage );
236
251err_t turbidity_get_ntu ( turbidity_t *ctx, float *ntu );
252
253#ifdef __cplusplus
254}
255#endif
256#endif // TURBIDITY_H
257
258 // turbidity
259
260// ------------------------------------------------------------------------ END
void turbidity_cfg_setup(turbidity_cfg_t *cfg)
Turbidity configuration object setup function.
err_t turbidity_init(turbidity_t *ctx, turbidity_cfg_t *cfg)
Turbidity initialization function.
err_t turbidity_get_adc_voltage(turbidity_t *ctx, float *voltage)
Turbidity get voltage function.
err_t turbidity_get_ntu(turbidity_t *ctx, float *ntu)
Turbidity get NTU function.
err_t turbidity_read_adc(turbidity_t *ctx, uint16_t *adc_val)
Turbidity read ADC function.
err_t turbidity_default_cfg(turbidity_t *ctx)
Turbidity default configuration function.
err_t turbidity_generic_read(turbidity_t *ctx, uint8_t *rx_buf, uint8_t rx_len)
Turbidity I2C reading function.
Turbidity Click configuration object.
Definition turbidity.h:123
uint32_t i2c_speed
Definition turbidity.h:127
pin_name_t scl
Definition turbidity.h:124
pin_name_t sda
Definition turbidity.h:125
uint8_t i2c_address
Definition turbidity.h:128
Turbidity Click context object.
Definition turbidity.h:109
i2c_master_t i2c
Definition turbidity.h:111
uint8_t slave_address
Definition turbidity.h:114
turbidity_return_value_t
Turbidity Click return value data.
Definition turbidity.h:137
@ TURBIDITY_OK
Definition turbidity.h:138
@ TURBIDITY_ERROR
Definition turbidity.h:139