upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
dfrph.h
Go to the documentation of this file.
1 /*
2  * Author: Noel Eck <noel.eck@intel.com>
3  * Copyright (c) 2015 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 "upm.h"
28 #include "mraa/aio.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
45 typedef struct _dfrph_context {
46  /* mraa aio pin context */
47  mraa_aio_context aio;
48  /* ADC reference */
49  float m_aref;
50  /* Raw count offset */
51  float m_offset;
52  /* Raw count scale */
53  float m_scale;
54 } *dfrph_context;
55 
61 dfrph_context dfrph_init(int16_t pin);
62 
67 void dfrph_close(dfrph_context dev);
68 
75 upm_result_t dfrph_set_aref(const dfrph_context dev, float aref);
76 
82 float dfrph_get_aref(const dfrph_context dev);
83 
91 upm_result_t dfrph_set_offset(const dfrph_context dev, float offset);
92 
100 upm_result_t dfrph_set_scale(const dfrph_context dev, float scale);
101 
108 upm_result_t dfrph_get_raw_volts(const dfrph_context dev, float *volts);
109 
116 upm_result_t dfrph_get_ph(const dfrph_context dev, float *value);
117 
118 #ifdef __cplusplus
119 }
120 #endif
struct _dfrph_context * dfrph_context
float dfrph_get_aref(const dfrph_context dev)
Definition: dfrph.c:73
upm_result_t dfrph_get_ph(const dfrph_context dev, float *value)
Definition: dfrph.c:101
void dfrph_close(dfrph_context dev)
Definition: dfrph.c:61
upm_result_t dfrph_set_aref(const dfrph_context dev, float aref)
Definition: dfrph.c:67
Definition: dfrph.h:45
dfrph_context dfrph_init(int16_t pin)
Definition: dfrph.c:30
upm_result_t dfrph_set_offset(const dfrph_context dev, float offset)
Definition: dfrph.c:78
upm_result_t dfrph_get_raw_volts(const dfrph_context dev, float *volts)
Definition: dfrph.c:90
upm_result_t dfrph_set_scale(const dfrph_context dev, float scale)
Definition: dfrph.c:84