a752c7ab
elopes
add first test an...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
/*
* Copyright (C) 2016 Inria
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup drivers_bmp180 BMP180 temperature and pressure sensor
* @ingroup drivers_sensors
* @brief Device driver interface for the BMP180 sensor.
* @{
*
* @file
* @brief Device driver interface for the BMP180 sensor.
*
* @author Alexandre Abadie <alexandre.abadie@inria.fr>
*/
#ifndef BMP180_H
#define BMP180_H
#include "saul.h"
#include "periph/i2c.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Oversampling modes
*/
typedef enum {
BMP180_ULTRALOWPOWER = 0,
BMP180_STANDARD,
BMP180_HIGHRES,
BMP180_ULTRAHIGHRES
} bmp180_oversampling_mode_t;
/**
* @brief Calibration struct for the BMP180 sensor
*/
typedef struct {
int16_t ac1; /**< ac1 coefficient */
int16_t ac2; /**< ac2 coefficient */
int16_t ac3; /**< ac3 coefficient */
int16_t b1; /**< b1 coefficient */
int16_t b2; /**< b2 coefficient */
int16_t mb; /**< mb coefficient */
int16_t mc; /**< mc coefficient */
int16_t md; /**< md coefficient */
uint16_t ac4; /**< ac4 coefficient */
uint16_t ac5; /**< ac5 coefficient */
uint16_t ac6; /**< ac6 coefficient */
} bmp180_calibration_t;
/**
* @brief Device initialization parameters
*/
typedef struct {
i2c_t i2c_dev; /**< I2C device which is used */
uint8_t i2c_addr; /**< I2C address */
bmp180_oversampling_mode_t oversampling; /**< Oversampling mode */
} bmp180_params_t;
/**
* @brief Device descriptor for the BMP180 sensor
*/
typedef struct {
bmp180_params_t params; /**< Device initialization parameters */
bmp180_calibration_t calibration; /**< Device calibration */
} bmp180_t;
/**
* @brief Status and error return codes
*/
enum {
BMP180_OK = 0, /**< everything was fine */
BMP180_ERR_NOI2C, /**< error initializing the I2C bus */
BMP180_ERR_NODEV, /**< did not detect BMP180 */
BMP180_ERR_NOCAL, /**< error when reading calibration values */
};
/**
* @brief Initialize the given BMP180 device
*
* @param[out] dev Initialized device descriptor of BMP180 device
* @param[in] params Initialization parameters
*
* @return BMP180_OK on success
* @return -BMP180_ERR_NOI2C if given I2C is not enabled in board config
* @return -BMP180_ERR_NODEV if not a BMP180 at given address
* @return -BMP180_ERR_NOCAL if an error occured when reading calibration values
*/
int bmp180_init(bmp180_t *dev, const bmp180_params_t *params);
/**
* @brief Read temperature value from the given BMP180 device, returned in d°C
*
* @param[in] dev Device descriptor of BMP180 device to read from
*
* @return Temperature in d°C
*/
int16_t bmp180_read_temperature(const bmp180_t *dev);
/**
* @brief Read pressure value from the given BMP180 device, returned in Pa
*
* @param[in] dev Device descriptor of BMP180 device to read from
*
* @return Pressure in Pa
*/
uint32_t bmp180_read_pressure(const bmp180_t *dev);
/**
* @brief Compute altitude, returned in m.
*
* @param[in] dev Device descriptor of BMP180 device to read from
* @param[in] pressure_0 The pressure at sea level in Pa
*
* @return Altitude in m
*/
int16_t bmp180_altitude(const bmp180_t *dev, uint32_t pressure_0);
/**
* @brief Compute pressure at sea level, returned in Pa.
*
* @param[in] dev Device descriptor of BMP180 device to read from
* @param[in] altitude Altitude in m
*
* @return Pressure at sea level in Pa
*/
uint32_t bmp180_sealevel_pressure(const bmp180_t *dev, int16_t altitude);
#ifdef __cplusplus
}
#endif
#endif /* BMP180_H */
/** @} */
|