upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
o2.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 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
46 typedef struct _o2_context {
47  /* mraa aio pin context */
48  mraa_aio_context aio;
49  /* Analog voltage reference */
50  float m_aRef;
51  /* Scale */
52  float m_scale;
53  /* Offset in sensor units */
54  float m_offset;
55 } *o2_context;
56 
62 o2_context o2_init(int16_t pin);
63 
68 void o2_close(o2_context dev);
69 
76 upm_result_t o2_set_aref(const o2_context dev, float aref);
77 
83 float o2_get_aref(const o2_context dev);
84 
92 upm_result_t o2_set_offset(const o2_context dev, float offset);
93 
99 float o2_get_offset(const o2_context dev);
100 
108 upm_result_t o2_set_scale(const o2_context dev, float scale);
109 
115 float o2_get_scale(const o2_context dev);
116 
123 upm_result_t o2_get_counts(const o2_context dev, int *value);
124 
131 upm_result_t o2_get_raw_volts(const o2_context dev, float *value);
132 
139 upm_result_t o2_get_value(const o2_context dev, float *value);
140 
141 #ifdef __cplusplus
142 }
143 #endif
upm_result_t o2_set_aref(const o2_context dev, float aref)
Definition: o2.c:64
upm_result_t o2_set_scale(const o2_context dev, float scale)
Definition: o2.c:86
upm_result_t o2_set_offset(const o2_context dev, float offset)
Definition: o2.c:75
float o2_get_scale(const o2_context dev)
Definition: o2.c:92
o2_context o2_init(int16_t pin)
Definition: o2.c:29
float o2_get_aref(const o2_context dev)
Definition: o2.c:70
upm_result_t o2_get_counts(const o2_context dev, int *value)
Definition: o2.c:97
void o2_close(o2_context dev)
Definition: o2.c:58
float o2_get_offset(const o2_context dev)
Definition: o2.c:81
upm_result_t o2_get_raw_volts(const o2_context dev, float *value)
Definition: o2.c:105
struct _o2_context * o2_context
upm_result_t o2_get_value(const o2_context dev, float *value)
Definition: o2.c:117
Definition: o2.h:46