upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Data Structures | Functions | Typedefs
Include dependency graph for rsc.h:

API Description

/*
* Author: Abhishek Malik <abhishek.malik@intel.com>
* Copyright (c) 2017 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include "upm_utilities.h"
#include "rsc.h"
int main(void) {
rsc_context dev = rsc_init(0, 9, 8);
rsc_set_data_rate(dev, N_DR_330_SPS);
rsc_set_mode(dev, NORMAL_MODE);
float pressure;
float temp;
while(1){
pressure = rsc_get_pressure(dev);
printf("Retrieved pressure: %f %d\n", pressure, dev->unit);
temp = rsc_get_temperature(dev);
printf("Retieved temperature: %f C\n", temp);
upm_delay_ms(500);
}
return 0;
}

Go to the source code of this file.

Data Structures

struct  _rsc_context
 

Functions

rsc_context rsc_init (int bus, int cs_ee_pin, int cs_adc_pin)
 
upm_result_t rsc_close (rsc_context dev)
 
upm_result_t rsc_get_sensor_name (rsc_context dev, uint8_t *sensor_name)
 
upm_result_t rsc_get_sensor_serial_number (rsc_context dev, uint8_t *rsc_number)
 
float rsc_get_pressure_range (rsc_context dev)
 
float rsc_get_minimum_pressure (rsc_context dev)
 
PRESSURE_U rsc_get_pressure_unit (rsc_context dev)
 
PRESSURE_T rsc_get_pressure_type (rsc_context dev)
 
upm_result_t rsc_get_initial_adc_values (rsc_context dev, uint8_t *adc_init_values)
 
upm_result_t rsc_retrieve_coefficients (rsc_context dev)
 
upm_result_t rsc_setup_adc (rsc_context dev, uint8_t *adc_init_values)
 
float rsc_get_temperature (rsc_context dev)
 
float rsc_get_pressure (rsc_context dev)
 
upm_result_t rsc_set_mode (rsc_context dev, RSC_MODE mode)
 
upm_result_t rsc_set_data_rate (rsc_context dev, RSC_DATA_RATE dr)
 

Typedefs

typedef struct _rsc_contextrsc_context
 

Function Documentation

rsc_context rsc_init ( int  bus,
int  cs_ee_pin,
int  cs_adc_pin 
)

RSC initialization.

This device supports SPI. The sensor has two chip select pins since there are two ways to access content on the sensor - EEPROM/ADC. We will not be using the SPI CS here because that would work for all SPI operations. Hence, you are expected to initialize any 2 gpio pins for CS by providing the pin numbers.

Parameters
busSPI bus to use.
cs_ee_pinThe CS pin for accessing the EEPROM
cs_adc_pinThe CS pin for accessing the ADC
Returns
The device context, or NULL if an error occurred.

Here is the call graph for this function:

upm_result_t rsc_close ( rsc_context  dev)

RSC Close function

Parameters
devThe device context

Here is the caller graph for this function:

upm_result_t rsc_get_sensor_name ( rsc_context  dev,
uint8_t *  sensor_name 
)

This function fills up a character array provided to it with the sensor name that it reads from the EEPROM. NOTE: The length of the array will always have to be RSC_SENSOR_NAME_LEN

Parameters
devThe device context
sensor_namePointer to a uint8_t array with length RSC_SENSOR_NAME_LEN. This array will be filled up with the sensor name read from the EEPROM.
Returns
UPM result.

Here is the caller graph for this function:

upm_result_t rsc_get_sensor_serial_number ( rsc_context  dev,
uint8_t *  rsc_number 
)

This function fills up a character array provided to it with the sensor serial number that it reads from the EEPROM. NOTE: The length of the array will always have to be RSC_SENSOR_NUMBER_LEN

Parameters
devThe device context
sensor_namePointer to a uint8_t array with length RSC_SENSOR_NUMBER_LEN. This array will be filled up with the serial number
Returns
UPM result.

Here is the caller graph for this function:

float rsc_get_pressure_range ( rsc_context  dev)

This function reads the EEPROM to retrieve the pressure range for the particular RSC device.

Parameters
devThe device context
Returns
Sensor pressure range in float

Here is the caller graph for this function:

float rsc_get_minimum_pressure ( rsc_context  dev)

This function reads the EEPROM to retrieve the minimum pressure that the sensor can read.

Parameters
devThe device context
Returns
Minimum pressure sensor can read in float

Here is the caller graph for this function:

PRESSURE_U rsc_get_pressure_unit ( rsc_context  dev)

This function reads the EEPROM to retrieve the pressure units that the pressure is read in

Parameters
devThe device context
Returns
enum PRESSURE_U

Here is the caller graph for this function:

PRESSURE_T rsc_get_pressure_type ( rsc_context  dev)

This function reads the EEPROM to retrieve the sensor pressure type

Parameters
devThe device context
Returns
enum PRESSURE_T

Here is the caller graph for this function:

upm_result_t rsc_get_initial_adc_values ( rsc_context  dev,
uint8_t *  adc_init_values 
)

This function reads the EEPROM to extract the values with which the ADC has to be initialized. NOTE: The length of the array will always be 4

Parameters
devThe device context
adc_init_valuesuint8_t pointer to an array containing the initial values for the ADC
Returns
UPM result.

Here is the caller graph for this function:

upm_result_t rsc_retrieve_coefficients ( rsc_context  dev)

This function is used to retrieve the coefficients from the EEPROM. Once retrieved, the function updates a 2 dimensional array in the sensor context with the latest values. This function doesn't return the coefficient values.

Parameters
devThe device context
Returns
UPM result.

Here is the caller graph for this function:

upm_result_t rsc_setup_adc ( rsc_context  dev,
uint8_t *  adc_init_values 
)

This function sets up the initial values in the ADC and also sets is to a default data rate - normal with 20 samples per second

Parameters
devThe device context
Returns
UPM result.

Here is the caller graph for this function:

float rsc_get_temperature ( rsc_context  dev)

Function to get the compensated temperature as read by the sensor.

Parameters
devThe device context
Returns
float temperature in degree Celsius

Here is the caller graph for this function:

float rsc_get_pressure ( rsc_context  dev)

Function to get the compensated pressure as read by the sensor.

Parameters
devThe device context
Returns
float pressure (units inH2O)

Here is the caller graph for this function:

upm_result_t rsc_set_mode ( rsc_context  dev,
RSC_MODE  mode 
)

Function to set the mode of the sensor.

Parameters
devThe device context
modemode of the sensor
Returns
UPM result.

Here is the caller graph for this function:

upm_result_t rsc_set_data_rate ( rsc_context  dev,
RSC_DATA_RATE  dr 
)

Function to set the data rate of the sensor.

Parameters
devThe device context
drdata rate of the sensor
Returns
UPM result.

Here is the call graph for this function:

Here is the caller graph for this function:

Typedef Documentation

typedef struct _rsc_context * rsc_context

Device context