Loading...
Searching...
No Matches

Driver for the Freescale MPL3115A2 pressure sensor. More...

Detailed Description

Driver for the Freescale MPL3115A2 pressure sensor.

The driver will initialize the sensor for pressure measurement. The conversion duration depends on oversample ratio. After initialization the sensor can be set active to run periodic measurements. The oversample ratio can be configured during sensor initialization.

This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.

Modules

 MPL3115A2 Pressure Sensor driver compile configuration
 

Files

file  mpl3115a2.h
 Interface definition for the MPL3115A2 sensor driver.
 
file  mpl3115a2_params.h
 Default configuration for MPL3115A2 devices.
 
file  mpl3115a2_reg.h
 Register definition for the MPL3115A2 sensor driver.
 

Data Structures

struct  mpl3115a2_params_t
 Configuration parameters. More...
 
struct  mpl3115a2_t
 Device descriptor for MPL3115A2 sensors. More...
 

Macros

#define MPL3115A2_I2C_ADDRESS   (0x60)
 MPL3115A2 Default Address.
 

Enumerations

enum  { MPL3115A2_OK , MPL3115A2_ERROR_I2C , MPL3115A2_ERROR_DEV , MPL3115A2_ERROR_CNF }
 Named return values. More...
 

Functions

int mpl3115a2_init (mpl3115a2_t *dev, const mpl3115a2_params_t *params)
 Initialize the MPL3115A2 sensor driver.
 
int mpl3115a2_reset (const mpl3115a2_t *dev)
 Reset the MPL3115A2 sensor.
 
int mpl3115a2_set_active (const mpl3115a2_t *dev)
 Set active mode, this enables periodic measurements.
 
int mpl3115a2_set_standby (const mpl3115a2_t *dev)
 Set standby mode.
 
int mpl3115a2_is_ready (const mpl3115a2_t *dev)
 Check for new set of measurement data.
 
int mpl3115a2_read_pressure (const mpl3115a2_t *dev, uint32_t *pres, uint8_t *status)
 Read sensor's data in pressure mode.
 
int mpl3115a2_read_temp (const mpl3115a2_t *dev, int16_t *temp)
 Read sensor's temperature.
 

Oversample Ratio configuration

enum  {
  MPL3115A2_OS_RATIO_1 = 0 , MPL3115A2_OS_RATIO_2 , MPL3115A2_OS_RATIO_4 , MPL3115A2_OS_RATIO_8 ,
  MPL3115A2_OS_RATIO_16 , MPL3115A2_OS_RATIO_32 , MPL3115A2_OS_RATIO_64 , MPL3115A2_OS_RATIO_128
}
 
#define MPL3115A2_OS_RATIO_DEFAULT   MPL3115A2_OS_RATIO_16
 Default Ratio.
 

Macro Definition Documentation

◆ MPL3115A2_I2C_ADDRESS

#define MPL3115A2_I2C_ADDRESS   (0x60)

MPL3115A2 Default Address.

Definition at line 56 of file mpl3115a2.h.

◆ MPL3115A2_OS_RATIO_DEFAULT

#define MPL3115A2_OS_RATIO_DEFAULT   MPL3115A2_OS_RATIO_16

Default Ratio.

Definition at line 72 of file mpl3115a2.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Named return values.

Enumerator
MPL3115A2_OK 

all good

MPL3115A2_ERROR_I2C 

I2C communication failed.

MPL3115A2_ERROR_DEV 

Device MPL3115A2 not found.

MPL3115A2_ERROR_CNF 

Device configuration failed.

Definition at line 46 of file mpl3115a2.h.

◆ anonymous enum

anonymous enum
Enumerator
MPL3115A2_OS_RATIO_1 

Oversample Ratio 1, conversion 6ms.

MPL3115A2_OS_RATIO_2 

Oversample Ratio 2, conversion 10ms.

MPL3115A2_OS_RATIO_4 

Oversample Ratio 4, conversion 18ms.

MPL3115A2_OS_RATIO_8 

Oversample Ratio 8, conversion 34ms.

MPL3115A2_OS_RATIO_16 

Oversample Ratio 16, conversion 66ms.

MPL3115A2_OS_RATIO_32 

Oversample Ratio 32, conversion 130ms.

MPL3115A2_OS_RATIO_64 

Oversample Ratio 64, conversion 258ms.

MPL3115A2_OS_RATIO_128 

Oversample Ratio 128, conversion 514ms.

Definition at line 62 of file mpl3115a2.h.

Function Documentation

◆ mpl3115a2_init()

int mpl3115a2_init ( mpl3115a2_t dev,
const mpl3115a2_params_t params 
)

Initialize the MPL3115A2 sensor driver.

Parameters
[out]devdevice descriptor of sensor to initialize
[in]paramsconfiguration parameters
Returns
MPL3115A2_OK on success
-MPL3115A2_ERROR_I2C on I2C bus error
-MPL3115A2_ERROR_DEV on device error
-MPL3115A2_ERROR_CNF on config error

◆ mpl3115a2_is_ready()

int mpl3115a2_is_ready ( const mpl3115a2_t dev)

Check for new set of measurement data.

Parameters
[in]devdevice descriptor of sensor
Returns
>0 if new data sample is ready
MPL3115A2_OK measurement in progress
-MPL3115A2_ERROR_I2C on error

◆ mpl3115a2_read_pressure()

int mpl3115a2_read_pressure ( const mpl3115a2_t dev,
uint32_t *  pres,
uint8_t *  status 
)

Read sensor's data in pressure mode.

Parameters
[in]devdevice descriptor of sensor
[out]prespressure in Pascals
[out]statussensor status register
Returns
MPL3115A2_OK on success,
-MPL3115A2_ERROR_I2C on error

◆ mpl3115a2_read_temp()

int mpl3115a2_read_temp ( const mpl3115a2_t dev,
int16_t *  temp 
)

Read sensor's temperature.

Parameters
[in]devdevice descriptor of sensor
[out]temptemperature in $^\circ C \cdot 10$
Returns
MPL3115A2_OK on success
-MPL3115A2_ERROR_I2C on error

◆ mpl3115a2_reset()

int mpl3115a2_reset ( const mpl3115a2_t dev)

Reset the MPL3115A2 sensor.

After that, the sensor should be reinitialized.

Parameters
[in]devdevice descriptor of sensor
Returns
MPL3115A2_OK on success
-MPL3115A2_ERROR_I2C on error

◆ mpl3115a2_set_active()

int mpl3115a2_set_active ( const mpl3115a2_t dev)

Set active mode, this enables periodic measurements.

Parameters
[in]devdevice descriptor of sensor
Returns
MPL3115A2_OK on success
-MPL3115A2_ERROR_I2C on error

◆ mpl3115a2_set_standby()

int mpl3115a2_set_standby ( const mpl3115a2_t dev)

Set standby mode.

Parameters
[in]devdevice descriptor of sensor
Returns
MPL3115A2_OK on success
-MPL3115A2_ERROR_I2C on error