mpl3115a2.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 PHYTEC Messtechnik GmbH
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
29 #ifndef MPL3115A2_H
30 #define MPL3115A2_H
31 
32 #include <stdint.h>
33 #include <stdbool.h>
34 #include "periph/i2c.h"
35 
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40 
41 #ifndef MPL3115A2_I2C_ADDRESS
42 #define MPL3115A2_I2C_ADDRESS 0x60
43 #endif
44 
45 #define MPL3115A2_OS_RATIO_1 0
46 #define MPL3115A2_OS_RATIO_2 1
47 #define MPL3115A2_OS_RATIO_4 2
48 #define MPL3115A2_OS_RATIO_8 3
49 #define MPL3115A2_OS_RATIO_16 4
50 #define MPL3115A2_OS_RATIO_32 5
51 #define MPL3115A2_OS_RATIO_64 6
52 #define MPL3115A2_OS_RATIO_128 7
53 #define MPL3115A2_OS_RATIO_DEFAULT MPL3115A2_OS_RATIO_128
55 #ifndef MPL3115A2_CONVERSION_TIME
56 #define MPL3115A2_CONVERSION_TIME 512000
57 #endif
58 
59 
63 typedef struct {
65  uint8_t addr;
66  bool initialized;
67 } mpl3115a2_t;
68 
78 int mpl3115a2_test(const mpl3115a2_t *dev);
79 
94 int mpl3115a2_init(mpl3115a2_t *dev, i2c_t i2c, uint8_t address, uint8_t os_ratio);
95 
104 int mpl3115a2_reset(mpl3115a2_t *dev);
105 
114 int mpl3115a2_set_active(const mpl3115a2_t *dev);
115 
124 int mpl3115a2_set_standby(const mpl3115a2_t *dev);
125 
135 int mpl3115a2_is_ready(const mpl3115a2_t *dev);
136 
147 int mpl3115a2_read_pressure(const mpl3115a2_t *dev, uint32_t *pres, uint8_t *status);
148 
158 int mpl3115a2_read_temp(const mpl3115a2_t *dev, int16_t *temp);
159 
160 #ifdef __cplusplus
161 }
162 #endif
163 
164 #endif /* MPL3115A2_H */
165 
int mpl3115a2_init(mpl3115a2_t *dev, i2c_t i2c, uint8_t address, uint8_t os_ratio)
Initialize the MPL3115A2 sensor driver.
int mpl3115a2_is_ready(const mpl3115a2_t *dev)
Check for new set of measurement data.
int mpl3115a2_reset(mpl3115a2_t *dev)
Reset the MPL3115A2 sensor.
bool initialized
sensor status, true if sensor is initialized
Definition: mpl3115a2.h:66
Device descriptor for MPL3115A2 sensors.
Definition: mpl3115a2.h:63
i2c_t i2c
I2C device, the sensor is connected to.
Definition: mpl3115a2.h:64
int mpl3115a2_read_temp(const mpl3115a2_t *dev, int16_t *temp)
Read sensor&#39;s temperature.
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:113
int mpl3115a2_read_pressure(const mpl3115a2_t *dev, uint32_t *pres, uint8_t *status)
Read sensor&#39;s data in pressure mode.
int mpl3115a2_test(const mpl3115a2_t *dev)
MPL3115A2 sensor test.
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.
uint8_t addr
the sensor&#39;s slave address on the I2C bus
Definition: mpl3115a2.h:65
Low-level I2C peripheral driver interface definition.