upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
ecezo.h
Go to the documentation of this file.
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2016 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * 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
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
25 #pragma once
26 
27 #include <stdint.h>
28 #include <upm.h>
29 #include <mraa/uart.h>
30 #include <mraa/i2c.h>
31 #include <mraa/gpio.h>
32 
33 #include "ecezo_defs.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
50  typedef struct _ecezo_context {
51  mraa_uart_context uart;
52  mraa_i2c_context i2c;
53 
54  // our values
55  float ec; // electrical conductivity
56  float tds; // total dissolved solids
57  float salinity;
58  float sg; // specific gravity
59 
60  } *ecezo_context;
61 
70  ecezo_context ecezo_uart_init(unsigned int uart, unsigned int baudrate);
71 
80  ecezo_context ecezo_i2c_init(unsigned int bus, uint8_t addr);
81 
85  void ecezo_close(ecezo_context dev);
86 
96  upm_result_t ecezo_update(const ecezo_context dev);
97 
110  upm_result_t ecezo_set_temperature(const ecezo_context dev, float temp);
111 
120  upm_result_t ecezo_set_k_value(const ecezo_context dev, float k);
121 
129  upm_result_t ecezo_set_sleep(const ecezo_context dev, bool enable);
130 
139  float ecezo_get_ec(const ecezo_context dev);
140 
149  float ecezo_get_tds(const ecezo_context dev);
150 
158  float ecezo_get_salinity(const ecezo_context dev);
159 
168  float ecezo_get_sg(const ecezo_context dev);
169 
201  upm_result_t ecezo_calibrate(const ecezo_context dev,
202  ECEZO_CALIBRATION_T cal,
203  float ec);
204 
220  upm_result_t ecezo_set_continuous(const ecezo_context dev, bool enable);
221 
237  int ecezo_send_command(const ecezo_context dev, char *cmd,
238  char *buffer, int len);
239 
250  int ecezo_read(const ecezo_context dev, char *buffer, size_t len);
251 
262  upm_result_t ecezo_write(const ecezo_context dev, char *buffer, size_t len);
263 
264 
265 #ifdef __cplusplus
266 }
267 #endif
float ecezo_get_salinity(const ecezo_context dev)
Definition: ecezo.c:624
int ecezo_send_command(const ecezo_context dev, char *cmd, char *buffer, int len)
Definition: ecezo.c:460
upm_result_t ecezo_set_temperature(const ecezo_context dev, float temp)
Definition: ecezo.c:326
upm_result_t ecezo_set_continuous(const ecezo_context dev, bool enable)
Definition: ecezo.c:314
ecezo_context ecezo_i2c_init(unsigned int bus, uint8_t addr)
Definition: ecezo.c:257
float ecezo_get_tds(const ecezo_context dev)
Definition: ecezo.c:617
void ecezo_close(ecezo_context dev)
Definition: ecezo.c:302
Definition: ecezo.h:50
float ecezo_get_sg(const ecezo_context dev)
Definition: ecezo.c:631
ecezo_context ecezo_uart_init(unsigned int uart, unsigned int baudrate)
Definition: ecezo.c:208
struct _ecezo_context * ecezo_context
int ecezo_read(const ecezo_context dev, char *buffer, size_t len)
Definition: ecezo.c:384
upm_result_t ecezo_write(const ecezo_context dev, char *buffer, size_t len)
Definition: ecezo.c:434
upm_result_t ecezo_set_sleep(const ecezo_context dev, bool enable)
Definition: ecezo.c:367
upm_result_t ecezo_calibrate(const ecezo_context dev, ECEZO_CALIBRATION_T cal, float ec)
Definition: ecezo.c:638
float ecezo_get_ec(const ecezo_context dev)
Definition: ecezo.c:610
upm_result_t ecezo_update(const ecezo_context dev)
Definition: ecezo.c:577
upm_result_t ecezo_set_k_value(const ecezo_context dev, float k)
Definition: ecezo.c:349