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 and set activ the sensor will make measurements at periodic times. The oversample ratio can be determined by 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_t
 Device descriptor for MPL3115A2 sensors. More...
 

Macros

#define MPL3115A2_I2C_ADDRESS   0x60
 Pressure Sensor Default Address.
 
#define MPL3115A2_OS_RATIO_1   0
 Oversample Ratio 1, conversion time 6 ms.
 
#define MPL3115A2_OS_RATIO_2   1
 Oversample Ratio 2, conversion time 10 ms.
 
#define MPL3115A2_OS_RATIO_4   2
 Oversample Ratio 4, conversion time 18 ms.
 
#define MPL3115A2_OS_RATIO_8   3
 Oversample Ratio 8, conversion time 34 ms.
 
#define MPL3115A2_OS_RATIO_16   4
 Oversample Ratio 16, conversion time 66 ms.
 
#define MPL3115A2_OS_RATIO_32   5
 Oversample Ratio 32, conversion time 130 ms.
 
#define MPL3115A2_OS_RATIO_64   6
 Oversample Ratio 64, conversion time 258 ms.
 
#define MPL3115A2_OS_RATIO_128   7
 Oversample Ratio 128, conversion time 512 ms.
 
#define MPL3115A2_OS_RATIO_DEFAULT   MPL3115A2_OS_RATIO_128
 Default Ratio for testing.
 
#define MPL3115A2_CONVERSION_TIME   512000
 Maximum Conversion Time in us.
 

Functions

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

Function Documentation

int mpl3115a2_init ( mpl3115a2_t dev,
i2c_t  i2c,
uint8_t  address,
uint8_t  os_ratio 
)
Parameters
[out]devdevice descriptor of sensor to initialize
[in]i2cI2C bus the sensor is connected to
[in]addresssensor's I2C slave address
[in]os_ratiooversample rate selection
Returns
0 on success
-1 if os_ratio parameter is wrong
-2 if initialization of I2C bus failed
-3 if sensor test failed
-4 if sensor configuration failed
int mpl3115a2_is_ready ( mpl3115a2_t dev)
Parameters
[in]devdevice descriptor of sensor
Returns
>0 if new data sample is ready
0 measurement in progress
-1 on error
int mpl3115a2_read_pressure ( mpl3115a2_t dev,
uint32_t *  pres,
uint8_t *  status 
)
Parameters
[in]devdevice descriptor of sensor
[out]prespressure in Pascals
[out]statussensor status register
Returns
0 on success
-1 on error
int mpl3115a2_read_temp ( mpl3115a2_t dev,
int16_t *  temp 
)
Parameters
[in]devdevice descriptor of sensor
[out]temptemperature in $^\circ C \cdot 10$
Returns
0 on success
-1 on error
int mpl3115a2_reset ( mpl3115a2_t dev)

After that, the sensor should be reinitialized.

Parameters
[out]devdevice descriptor of sensor
Returns
0 on success
-1 on error
int mpl3115a2_set_active ( mpl3115a2_t dev)
Parameters
[out]devdevice descriptor of sensor
Returns
0 on success
-1 on error
int mpl3115a2_set_standby ( mpl3115a2_t dev)
Parameters
[in]devdevice descriptor of sensor
Returns
0 on success
-1 on error
int mpl3115a2_test ( mpl3115a2_t dev)

This function looks for Device ID of the MPL3115A2 sensor.

Parameters
[in]devdevice descriptor of sensor
Returns
0 on success
-1 on error