Loading...
Searching...
No Matches
ABP2 series Honeywell pressure and temperature sensor driver

SPI and I2C pressure and temperature sensor driver. More...

Detailed Description

SPI and I2C pressure and temperature sensor driver.

Description

The unit and the range depend on the part number of the sensor. The default parameters assume a 0..160 mbar model. It is the responsibility of the user to use homogeneous units, depending on the actual sensor being used. The pressure range is set when calling abp2_init().

This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities. The functions return 0 on success or a negative value made from errno.h on error.

Usage

See RIOT/tests/drivers/abp2 for an example application using this driver.

Add the following modules to the application makefile:

USEMODULE += abp2
USEMODULE += abp2_spi
Device descriptor for ABP2 sensors.
Definition abp2.h:148

When the I2C version is supported, abp2_i2c can be used for I2C sensors instead of abp2_spi.

To use the SAUL interface, add also to the makefile:

USEMODULE += saul_default

Initialize the driver by calling abp2_init().

When a measurement is started on the sensor, its internal ADC converts both pressure and temperature. The conversion takes about 5ms. These two values are retrieved in a single bus transfer.

There are three ways to use the driver:

The first one will block for about 5ms and return the latest data, while the second one will return almost immediately but will return data from the previous ADC conversion.

Caveats

This driver currently doesn't support the I2C flavor of these sensors.

Topics

 Status bits
 Macro definitions to manipulate the bits of the status byte.
 

Files

file  abp2_params.h
 Default configuration for ABP2 capaticance-to-digital converter.
 
file  abp2.h
 Honeywell ABP2 series pressure and temperature sensor driver.
 

Data Structures

struct  abp2_params
 Parameters for ABP2 sensors. More...
 
struct  abp2
 Device descriptor for ABP2 sensors. More...
 
struct  abp2_raw
 Raw values read from a ABP2 sensor. More...
 

Typedefs

typedef struct abp2_params abp2_params_t
 Parameters for ABP2 sensors.
 
typedef struct abp2 abp2_t
 Device descriptor for ABP2 sensors.
 
typedef struct abp2_raw abp2_raw_t
 Raw values read from a ABP2 sensor.
 

Functions

int abp2_init (abp2_t *dev, const abp2_params_t *params)
 Initialize the ABP2 sensor.
 
int abp2_measure (const abp2_t *dev)
 Let the sensor make one measurement.
 
int abp2_read (const abp2_t *dev, int32_t *press, int32_t *temp)
 Measure pressure and temperature (blocking version).
 
int abp2_read_nb (const abp2_t *dev, int32_t *press, int32_t *temp)
 Measure pressure and temperature (non-blocking version).
 
uint8_t abp2_getstatus (const abp2_t *dev)
 Read the status byte of the sensor.
 
int abp2_read_raw (const abp2_t *dev, abp2_raw_t *raw_values)
 Read pressure and temperature raw values.
 
int abp2_measure_read (const abp2_t *dev, abp2_raw_t *raw_values)
 Start measurement and read previous pressure and temperature raw values.
 
int32_t abp2_pressure (const abp2_t *dev, const abp2_raw_t *raw_values)
 Convert ADC counts to pressure.
 
int32_t abp2_temperature (const abp2_t *dev, const abp2_raw_t *raw_values)
 Convert ADC counts to temperature .
 

Typedef Documentation

◆ abp2_params_t

typedef struct abp2_params abp2_params_t

Parameters for ABP2 sensors.

The range must be set in thousandths of sensor unit. For example, if the sensor unit is mbar, set the rangeMin and rangeMax properties in µbar.

Function Documentation

◆ abp2_getstatus()

uint8_t abp2_getstatus ( const abp2_t * dev)

Read the status byte of the sensor.

Parameters
[in]devSensor device descriptor.
See also
Status bits
Returns
The status byte.

◆ abp2_init()

int abp2_init ( abp2_t * dev,
const abp2_params_t * params )

Initialize the ABP2 sensor.

Parameters
[in]devSensor device descriptor.
[in]paramsSensor parameters.
See also
abp2_params.

Assign the parameters params to the device descriptor dev. Poll the device until the busy flag clears or the operation times out. On SPI version, init the chip select pin.

Note
The bus is expected to be initialized when calling this function.
params sets the sensor range.
Returns
0 on success
-EIO on bus error or -ETIMEDOUT on timeout.

◆ abp2_measure()

int abp2_measure ( const abp2_t * dev)

Let the sensor make one measurement.

Parameters
[in]devSensor device descriptor.

This function lets the sensor transition from standby to operation mode and make one measurement, after which it will automatically return to standby mode. Call abp2_read_raw() to retrieve the data.

Returns
0 on success
-ENODATA on sensor error.

◆ abp2_measure_read()

int abp2_measure_read ( const abp2_t * dev,
abp2_raw_t * raw_values )

Start measurement and read previous pressure and temperature raw values.

Parameters
[in]devSensor device descriptor.
[out]raw_valuesRaw values read from the sensor.

Read the raw values, i.e. ADC counts that result from the previous measurement. Then, populate raw_values. The raw values can be converted to physical quantities with abp2_pressure() and abp2_temperature().

Precondition
A measurement must have been initiated by abp2_measure() or a previous call to this function, in order to retrieve valid data.
Note
This function leads to concise user code. However, in order to get valid data, it must be called periodically, and at short intervals. If the application favors power savings i.e. low frequency measurements, then abp2_measure() and abp2_read_raw() are a better option.
Returns
0 on success
-ENODATA on sensor error.

◆ abp2_pressure()

int32_t abp2_pressure ( const abp2_t * dev,
const abp2_raw_t * raw_values )

Convert ADC counts to pressure.

Parameters
[in]devSensor device descriptor.
[in]raw_valuesRaw values read from the sensor.
See also
abp2_params to know how to set the sensor range.
Returns
The pressure in thousandths of user units, as set in the parameters of abp2_init().

◆ abp2_read()

int abp2_read ( const abp2_t * dev,
int32_t * press,
int32_t * temp )

Measure pressure and temperature (blocking version).

Parameters
[in]devSensor device descriptor.
[out]pressPressure value read from the sensor (thousandths of sensor unit).
[out]tempTemperature read from the sensor (milli-degrees Celsius).

This function is blocking. It starts a conversion on the sensor ADC for both pressure and temperature, waits until the busy flag clears or for a 10ms timeout, reads the values from the sensor and converts them to physical quantities.

See also
The non-blocking version: abp2_read_nb().
Returns
0 on success
-ETIMEDOUT on timeout
-ENODATA on sensor error

◆ abp2_read_nb()

int abp2_read_nb ( const abp2_t * dev,
int32_t * press,
int32_t * temp )

Measure pressure and temperature (non-blocking version).

Parameters
[in]devSensor device descriptor.
[out]pressPressure value read from the sensor (thousandths of sensor unit).
[out]tempTemperature read from the sensor (milli-degrees Celsius).

This function starts a conversion on the sensor ADC and reads the values from the previous conversion in a single bus transfer and converts them to physical quantities.

See also
The blocking version: abp2_read().
Returns
0 on success
-ENODATA on sensor error

◆ abp2_read_raw()

int abp2_read_raw ( const abp2_t * dev,
abp2_raw_t * raw_values )

Read pressure and temperature raw values.

Parameters
[in]devSensor device descriptor.
[out]raw_valuesRaw values read from the sensor.

Read the raw values, i.e. ADC counts and populate raw_values. The raw values can be converted to physical quantities with abp2_pressure() and abp2_temperature().

Precondition
A measurement must have been initiated by abp2_measure() and have completed (ca. 5ms).
Returns
0 on success
-ENODATA on sensor error.

◆ abp2_temperature()

int32_t abp2_temperature ( const abp2_t * dev,
const abp2_raw_t * raw_values )

Convert ADC counts to temperature .

Parameters
[in]devSensor device descriptor.
[in]raw_valuesRaw values read from the sensor.
Returns
The temperature in milli-degrees Celsius.