upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
mqx.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 
62 typedef struct _mqx_context {
63  /* mraa aio pin context */
64  mraa_aio_context aio;
65  /* Analog voltage reference */
66  float m_aRef;
67  /* Scale */
68  float m_scale;
69  /* Offset in sensor units */
70  float m_offset;
71 } *mqx_context;
72 
78 mqx_context mqx_init(int16_t pin);
79 
84 void mqx_close(mqx_context dev);
85 
92 upm_result_t mqx_set_aref(const mqx_context dev, float aref);
93 
101 upm_result_t mqx_set_scale(const mqx_context dev, float scale);
102 
110 upm_result_t mqx_set_offset(const mqx_context dev, float offset);
111 
117 float mqx_get_aref(const mqx_context dev);
118 
124 float mqx_get_scale(const mqx_context dev);
125 
131 float mqx_get_offset(const mqx_context dev);
132 
139 upm_result_t mqx_get_normalized(const mqx_context dev, float *value);
140 
147 upm_result_t mqx_get_raw_volts(const mqx_context dev, float *value);
148 
155 upm_result_t mqx_get_volts(const mqx_context dev, float *value);
156 #ifdef __cplusplus
157 }
158 #endif
upm_result_t mqx_set_aref(const mqx_context dev, float aref)
Definition: mqx.c:67
Definition: mqx.h:62
void mqx_close(mqx_context dev)
Definition: mqx.c:61
upm_result_t mqx_get_raw_volts(const mqx_context dev, float *value)
Definition: mqx.c:108
float mqx_get_aref(const mqx_context dev)
Definition: mqx.c:85
upm_result_t mqx_set_offset(const mqx_context dev, float offset)
Definition: mqx.c:79
float mqx_get_offset(const mqx_context dev)
Definition: mqx.c:95
upm_result_t mqx_set_scale(const mqx_context dev, float scale)
Definition: mqx.c:73
upm_result_t mqx_get_volts(const mqx_context dev, float *value)
Definition: mqx.c:120
struct _mqx_context * mqx_context
float mqx_get_scale(const mqx_context dev)
Definition: mqx.c:90
mqx_context mqx_init(int16_t pin)
Definition: mqx.c:30
upm_result_t mqx_get_normalized(const mqx_context dev, float *value)
Definition: mqx.c:100