mpl3115a2.h¶
Interface definition for the MPL3115A2 sensor driver.
-
MPL3115A2_OS_RATIO_DEFAULT
¶ Default Ratio.
1
MPL3115A2_OS_RATIO_16
-
enum
@139
¶ - MPL3115A2_OS_RATIO_1
= 0
- 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.
- MPL3115A2_OS_RATIO_1
-
MPL3115A2_I2C_ADDRESS
¶ MPL3115A2 Default Address.
1
(0x60)
-
MPL3115A2_CONVERSION_TIME
¶ Maximum Conversion Time in microseconds [us].
1
(514000UL)
Note
Conversion time is: ((oversampling ratio * 4) + 2) * 1000 us
-
enum
@138
¶ - MPL3115A2_OK
- all good
- MPL3115A2_ERROR_I2C
- I2C communication failed.
- MPL3115A2_ERROR_DEV
- Device MPL3115A2 not found.
- MPL3115A2_ERROR_CNF
- Device configuration failed.
-
int
mpl3115a2_init
(mpl3115a2_t * dev, const mpl3115a2_params_t * params)¶ Initialize the MPL3115A2 sensor driver.
Parameters
dev: device descriptor of sensor to initialize params: configuration parameters Return values
- MPL3115A2_OK on success
- -MPL3115A2_ERROR_I2C on I2C bus error
- -MPL3115A2_ERROR_DEV on device error
- -MPL3115A2_ERROR_CNF on config error
-
int
mpl3115a2_reset
(const mpl3115a2_t * dev)¶ Reset the MPL3115A2 sensor.
After that, the sensor should be reinitialized.
Parameters
dev: device descriptor of sensor Return values
- MPL3115A2_OK on success
- -MPL3115A2_ERROR_I2C on error
-
int
mpl3115a2_set_active
(const mpl3115a2_t * dev)¶ Set active mode, this enables periodic measurements.
Parameters
dev: device descriptor of sensor Return values
- MPL3115A2_OK on success
- -MPL3115A2_ERROR_I2C on error
-
int
mpl3115a2_set_standby
(const mpl3115a2_t * dev)¶ Set standby mode.
Parameters
dev: device descriptor of sensor Return values
- MPL3115A2_OK on success
- -MPL3115A2_ERROR_I2C on error
-
int
mpl3115a2_is_ready
(const mpl3115a2_t * dev)¶ Check for new set of measurement data.
Parameters
dev: device descriptor of sensor Return values
- >0 if new data sample is ready
- MPL3115A2_OK measurement in progress
- -MPL3115A2_ERROR_I2C on error
-
int
mpl3115a2_read_pressure
(const mpl3115a2_t * dev, uint32_t * pres, uint8_t * status)¶ Read sensor’s data in pressure mode.
Parameters
dev: device descriptor of sensor pres: pressure in Pascals status: sensor status register Return values
- MPL3115A2_OK on success,
- -MPL3115A2_ERROR_I2C on error
-
int
mpl3115a2_read_temp
(const mpl3115a2_t * dev, int16_t * temp)¶ Read sensor’s temperature.
Parameters
dev: device descriptor of sensor temp: temperature in Return values
- MPL3115A2_OK on success
- -MPL3115A2_ERROR_I2C on error
-
struct
mpl3115a2_params_t
¶ Configuration parameters.
-
i2c.h::i2c_t
i2c
¶ I2C bus the device is connected to.
-
uint8_t
addr
¶ I2C bus address of the device.
-
uint8_t
ratio
¶ MPL3115A2 oversampling ratio.
-
-
struct
mpl3115a2_t
¶ Device descriptor for MPL3115A2 sensors.
-
mpl3115a2_params_t
params
¶ device configuration parameters
-
mpl3115a2_params_t