MPL3115A2 Pressure Sensor

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

Detailed Description

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.

Files

file  mpl3115a2.h
 Interface definition for the MPL3115A2 sensor driver.
 
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.
 
#define MPL3115A2_CONVERSION_TIME   (514000UL)
 Maximum Conversion Time in microseconds [us]. More...
 

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. More...
 
int mpl3115a2_reset (const mpl3115a2_t *dev)
 Reset the MPL3115A2 sensor. More...
 
int mpl3115a2_set_active (const mpl3115a2_t *dev)
 Set active mode, this enables periodic measurements. More...
 
int mpl3115a2_set_standby (const mpl3115a2_t *dev)
 Set standby mode. More...
 
int mpl3115a2_is_ready (const mpl3115a2_t *dev)
 Check for new set of measurement data. More...
 
int mpl3115a2_read_pressure (const mpl3115a2_t *dev, uint32_t *pres, uint8_t *status)
 Read sensor's data in pressure mode. More...
 
int mpl3115a2_read_temp (const mpl3115a2_t *dev, int16_t *temp)
 Read sensor's temperature. More...
 

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_CONVERSION_TIME

#define MPL3115A2_CONVERSION_TIME   (514000UL)
Note
Conversion time is: ((oversampling ratio * 4) + 2) * 1000 us

Definition at line 81 of file mpl3115a2.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
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 44 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 
)
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)
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 
)
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 
)
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)

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)
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)
Parameters
[in]devdevice descriptor of sensor
Returns
MPL3115A2_OK on success
-MPL3115A2_ERROR_I2C on error