mpl3115a2.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 PHYTEC Messtechnik GmbH
3  * 2017 HAW Hamburg
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
31 #ifndef MPL3115A2_H
32 #define MPL3115A2_H
33 
34 #include <stdint.h>
35 #include <stdbool.h>
36 #include "periph/i2c.h"
37 
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #endif
42 
46 enum {
51 };
52 
56 #define MPL3115A2_I2C_ADDRESS (0x60)
57 
62 enum {
71 };
72 #define MPL3115A2_OS_RATIO_DEFAULT MPL3115A2_OS_RATIO_16
85 #ifndef MPL3115A2_CONVERSION_TIME
86 #define MPL3115A2_CONVERSION_TIME (514000UL)
87 #endif
88 
93 typedef struct {
95  uint8_t addr;
96  uint8_t ratio;
98 
102 typedef struct {
104 } mpl3115a2_t;
105 
117 int mpl3115a2_init(mpl3115a2_t *dev, const mpl3115a2_params_t *params);
118 
127 int mpl3115a2_reset(const mpl3115a2_t *dev);
128 
137 int mpl3115a2_set_active(const mpl3115a2_t *dev);
138 
147 int mpl3115a2_set_standby(const mpl3115a2_t *dev);
148 
158 int mpl3115a2_is_ready(const mpl3115a2_t *dev);
159 
170 int mpl3115a2_read_pressure(const mpl3115a2_t *dev, uint32_t *pres, uint8_t *status);
171 
181 int mpl3115a2_read_temp(const mpl3115a2_t *dev, int16_t *temp);
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 #endif /* MPL3115A2_H */
188 
MPL3115A2_OK
@ MPL3115A2_OK
all good
Definition: mpl3115a2.h:47
MPL3115A2_ERROR_DEV
@ MPL3115A2_ERROR_DEV
Device MPL3115A2 not found.
Definition: mpl3115a2.h:49
mpl3115a2_is_ready
int mpl3115a2_is_ready(const mpl3115a2_t *dev)
Check for new set of measurement data.
mpl3115a2_read_temp
int mpl3115a2_read_temp(const mpl3115a2_t *dev, int16_t *temp)
Read sensor's temperature.
mpl3115a2_t
Device descriptor for MPL3115A2 sensors.
Definition: mpl3115a2.h:102
MPL3115A2_OS_RATIO_1
@ MPL3115A2_OS_RATIO_1
Oversample Ratio 1, conversion 6ms.
Definition: mpl3115a2.h:63
mpl3115a2_params_t::ratio
uint8_t ratio
MPL3115A2 oversampling ratio.
Definition: mpl3115a2.h:96
MPL3115A2_OS_RATIO_2
@ MPL3115A2_OS_RATIO_2
Oversample Ratio 2, conversion 10ms.
Definition: mpl3115a2.h:64
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
mpl3115a2_init
int mpl3115a2_init(mpl3115a2_t *dev, const mpl3115a2_params_t *params)
Initialize the MPL3115A2 sensor driver.
MPL3115A2_OS_RATIO_8
@ MPL3115A2_OS_RATIO_8
Oversample Ratio 8, conversion 34ms.
Definition: mpl3115a2.h:66
mpl3115a2_read_pressure
int mpl3115a2_read_pressure(const mpl3115a2_t *dev, uint32_t *pres, uint8_t *status)
Read sensor's data in pressure mode.
mpl3115a2_params_t
Configuration parameters.
Definition: mpl3115a2.h:93
MPL3115A2_OS_RATIO_4
@ MPL3115A2_OS_RATIO_4
Oversample Ratio 4, conversion 18ms.
Definition: mpl3115a2.h:65
mpl3115a2_t::params
mpl3115a2_params_t params
device configuration parameters
Definition: mpl3115a2.h:103
mpl3115a2_params_t::addr
uint8_t addr
I2C bus address of the device.
Definition: mpl3115a2.h:95
MPL3115A2_OS_RATIO_128
@ MPL3115A2_OS_RATIO_128
Oversample Ratio 128, conversion 514ms.
Definition: mpl3115a2.h:70
MPL3115A2_OS_RATIO_16
@ MPL3115A2_OS_RATIO_16
Oversample Ratio 16, conversion 66ms.
Definition: mpl3115a2.h:67
MPL3115A2_OS_RATIO_32
@ MPL3115A2_OS_RATIO_32
Oversample Ratio 32, conversion 130ms.
Definition: mpl3115a2.h:68
MPL3115A2_ERROR_I2C
@ MPL3115A2_ERROR_I2C
I2C communication failed.
Definition: mpl3115a2.h:48
mpl3115a2_set_active
int mpl3115a2_set_active(const mpl3115a2_t *dev)
Set active mode, this enables periodic measurements.
mpl3115a2_set_standby
int mpl3115a2_set_standby(const mpl3115a2_t *dev)
Set standby mode.
i2c.h
Low-level I2C peripheral driver interface definition.
mpl3115a2_params_t::i2c
i2c_t i2c
I2C bus the device is connected to.
Definition: mpl3115a2.h:94
mpl3115a2_reset
int mpl3115a2_reset(const mpl3115a2_t *dev)
Reset the MPL3115A2 sensor.
MPL3115A2_ERROR_CNF
@ MPL3115A2_ERROR_CNF
Device configuration failed.
Definition: mpl3115a2.h:50
MPL3115A2_OS_RATIO_64
@ MPL3115A2_OS_RATIO_64
Oversample Ratio 64, conversion 258ms.
Definition: mpl3115a2.h:69