upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Data Structures | Functions | Macros | Typedefs | Enumerations
abp.h File Reference
Include dependency graph for abp.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 <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "abp.h"
#include "upm_utilities.h"
int main()
{
abp_context dev = abp_init(0, ABP_DEFAULT_ADDRESS);
if(dev == NULL) {
printf("Unable to initialize sensor\n");
return 0;
}
while(1){
abp_update(dev);
printf("Retrieved pressure value: %f\n", abp_get_pressure(dev));
printf("Retrieved temperature value: %f\n", abp_get_temperature(dev));
upm_delay(1);
}
return 0;
}

Go to the source code of this file.

Data Structures

struct  _abp_context
 

Functions

abp_context abp_init (int bus, uint8_t dev_address)
 
void abp_close (abp_context dev)
 
float abp_get_pressure (abp_context dev)
 
float abp_get_temperature (abp_context dev)
 
void abp_set_max_pressure (abp_context dev, int max)
 
void abp_set_min_pressure (abp_context dev, int min)
 
upm_result_t abp_update (abp_context dev)
 

Macros

#define ABP_DEFAULT_ADDRESS   0x28
 
#define OUTPUT_10_PERCENT_COUNT   1638
 
#define OUTPUT_90_PERCENT_COUNT   14746
 
#define ABP_PRESSURE_MAX   5
 
#define ABP_PRESSURE_MIN   0
 
#define ABP_PRESSURE_HIGH_BYTE_MASK   0x3f
 
#define ABP_TEMPERATURE_LOW_BYTE_SHIFT   5
 
#define ABP_TEMPERATURE_MASK   0x7ff
 

Typedefs

typedef struct _abp_contextabp_context
 

Enumerations

enum  ABP_STATUS { NORMAL_OPERATION = 0, COMMAND_MODE, STALE_DATA, DIAGNOSTIC }
 

Function Documentation

abp_context abp_init ( int  bus,
uint8_t  dev_address 
)

ABP Initialization function

Parameters
busI2C bus to use
Returns
device context pointer
void abp_close ( abp_context  dev)

ABP Close function

Parameters
devabp_context pointer

Here is the caller graph for this function:

float abp_get_pressure ( abp_context  dev)

Function to get the compensated pressure. The datasheet provides a way to calculate the pressure. In order to know the units take a look at the datasheet.

Parameters
devabp_context pointer
Returns
float compensated pressure value

Here is the caller graph for this function:

float abp_get_temperature ( abp_context  dev)

Function to retrieve the compensated temperature values. All ABP seem to calculate temperature in degree Celsius. (The above fact needs to be verified) NOTE: This functionality is not available in all the ABP sensors.

Parameters
devabp_context pointer
Returns
float compensated temperature value

Here is the caller graph for this function:

void abp_set_max_pressure ( abp_context  dev,
int  max 
)

Function to set the max pressure that the sensor can read, can be retrieved from the datasheet, if this function is not explicitly called to the set the max value, then a default max value of 5 will be set.

Parameters
devabp_context pointer
maxint maximum pressure value possible

Here is the caller graph for this function:

void abp_set_min_pressure ( abp_context  dev,
int  min 
)

Function to set the min pressure that the sensor can read, can be retrieved from the datasheet, if this function is not explicitly called to the set the min value, then a default min value of 5 will be set.

Parameters
devabp_context pointer
minint minimum pressure value possible

Here is the caller graph for this function:

upm_result_t abp_update ( abp_context  dev)

This function has to be called before calling either of the get temperature or get pressure functions. This function updates the device context with the latest values. Not calling this function will lead to stale values.

Parameters
devabp_context pointer

Here is the caller graph for this function: