upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
rsc.h
Go to the documentation of this file.
1 /*
2  * Author: Abhishek Malik <abhishek.malik@intel.com>
3  * Copyright (c) 2017 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 <stdlib.h>
28 #include <unistd.h>
29 #include <stdio.h>
30 #include <string.h>
31 
32 #include "upm.h"
33 #include "mraa/spi.h"
34 #include "mraa/gpio.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include "rsc_regs.h"
52 typedef struct _rsc_context {
53  mraa_spi_context spi;
54  mraa_gpio_context cs_ee;
55  mraa_gpio_context cs_adc;
56  int spi_bus_number;
57  float coeff_matrix[RSC_COEFF_T_ROW_NO][RSC_COEFF_T_COL_NO];
58  PRESSURE_U unit;
59  PRESSURE_T type;
60  float pressure_range;
61  float min_pressure_val;
62  RSC_DATA_RATE data_rate;
63  RSC_MODE mode;
64  uint16_t t_raw;
65 } *rsc_context;
66 
82 rsc_context rsc_init(int bus, int cs_ee_pin, int cs_adc_pin);
83 
89 upm_result_t rsc_close(rsc_context dev);
90 
102 upm_result_t rsc_get_sensor_name(rsc_context dev, uint8_t* sensor_name);
103 
114 upm_result_t rsc_get_sensor_serial_number(rsc_context dev, uint8_t* rsc_number);
115 
124 
133 
141 PRESSURE_U rsc_get_pressure_unit(rsc_context dev);
142 
149 PRESSURE_T rsc_get_pressure_type(rsc_context dev);
150 
161 upm_result_t rsc_get_initial_adc_values(rsc_context dev, uint8_t* adc_init_values);
162 
172 upm_result_t rsc_retrieve_coefficients(rsc_context dev);
173 
181 upm_result_t rsc_setup_adc(rsc_context dev, uint8_t* adc_init_values);
182 
190 
197 float rsc_get_pressure(rsc_context dev);
198 
206 upm_result_t rsc_set_mode(rsc_context dev, RSC_MODE mode);
207 
215 upm_result_t rsc_set_data_rate(rsc_context dev, RSC_DATA_RATE dr);
216 
217 #ifdef __cplusplus
218 }
219 #endif
upm_result_t rsc_setup_adc(rsc_context dev, uint8_t *adc_init_values)
Definition: rsc.c:461
struct _rsc_context * rsc_context
float rsc_get_pressure_range(rsc_context dev)
Definition: rsc.c:185
upm_result_t rsc_get_sensor_serial_number(rsc_context dev, uint8_t *rsc_number)
Definition: rsc.c:174
float rsc_get_minimum_pressure(rsc_context dev)
Definition: rsc.c:198
PRESSURE_U rsc_get_pressure_unit(rsc_context dev)
Definition: rsc.c:211
upm_result_t rsc_close(rsc_context dev)
Definition: rsc.c:124
upm_result_t rsc_retrieve_coefficients(rsc_context dev)
Definition: rsc.c:278
float rsc_get_pressure(rsc_context dev)
Definition: rsc.c:431
upm_result_t rsc_get_sensor_name(rsc_context dev, uint8_t *sensor_name)
Definition: rsc.c:163
upm_result_t rsc_get_initial_adc_values(rsc_context dev, uint8_t *adc_init_values)
Definition: rsc.c:264
upm_result_t rsc_set_data_rate(rsc_context dev, RSC_DATA_RATE dr)
Definition: rsc.c:334
float rsc_get_temperature(rsc_context dev)
Definition: rsc.c:418
PRESSURE_T rsc_get_pressure_type(rsc_context dev)
Definition: rsc.c:240
upm_result_t rsc_set_mode(rsc_context dev, RSC_MODE mode)
Definition: rsc.c:361
Definition: rsc.h:52
rsc_context rsc_init(int bus, int cs_ee_pin, int cs_adc_pin)
Definition: rsc.c:37