Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
bmp280.h
Go to the documentation of this file.
1 /*
2  * Chris Efstathiou hendrixgr@gmail.com
3  * Florian Sansou florian.sansou@enac.fr
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
28 #ifndef BMP280_H
29 #define BMP280_H
30 
31 /* Header includes */
33 #include "mcu_periph/i2c.h"
34 #include "mcu_periph/spi.h"
35 
36 struct bmp280_i2c_t {
37  struct i2c_periph *p;
38  struct i2c_transaction trans;
40 };
41 
42 struct bmp280_spi_t {
43  struct spi_periph *p;
45  struct spi_transaction trans;
46 
48  uint8_t rx_buf[50]; //< Receive buffer
49 };
50 
51 /* Possible communication busses for the bmp280 driver */
55 };
56 
59  BMP_280
60 };
61 
62 /* Different states the bmp driver can be in */
70 };
71 
72 // brief Register Trim Variables
86  int64_t t_fine;
87 };
88 
89 
90 struct bmp280_t {
91  enum bmp280_status_t status;
92  enum bmp_device_t device;
93  bool initialized;
94  volatile bool data_available;
98  float pressure;
99  float temperature;
100  enum bmp280_bus_t bus;
101  union {
102  struct bmp280_spi_t spi;
103  struct bmp280_i2c_t i2c;
104  };
108 
110 };
111 
112 
113 extern void bmp280_read_eeprom_calib(struct bmp280_t *bmp);
114 extern void bmp280_init(struct bmp280_t *bmp);
115 extern void bmp280_periodic(struct bmp280_t *bmp);
116 extern void bmp280_event(struct bmp280_t *bmp);
117 
118 #endif /* BMP280_H */
void bmp280_periodic(struct bmp280_t *bmp)
Should be called periodically to request sensor readings.
Definition: bmp280.c:101
uint8_t slave_addr
The I2C slave address on the bus.
Definition: bmp280.h:39
struct bmp280_reg_calib_data_t calib
calibration data
Definition: bmp280.h:95
void bmp280_init(struct bmp280_t *bmp)
Initialize the bmp280 sensor instance.
Definition: bmp280.c:48
enum bmp280_status_t status
state machine status
Definition: bmp280.h:91
volatile bool data_available
data ready flag
Definition: bmp280.h:94
void bmp280_read_eeprom_calib(struct bmp280_t *bmp)
uint8_t slave_idx
Slave index used for Slave Select.
Definition: bmp280.h:44
uint8_t config_idx
The current configuration index.
Definition: bmp280.h:109
uint8_t * tx_buffer
Definition: bmp280.h:106
float temperature
temperature in deg Celcius
Definition: bmp280.h:99
uint32_t raw_temperature
uncompensated temperature
Definition: bmp280.h:97
bmp280_bus_t
Definition: bmp280.h:52
@ BMP280_I2C
Definition: bmp280.h:54
@ BMP280_SPI
Definition: bmp280.h:53
bmp280_status_t
Definition: bmp280.h:63
@ BMP280_STATUS_READ_DATA_REGS
Definition: bmp280.h:69
@ BMP280_STATUS_READ_STATUS_REG
Definition: bmp280.h:68
@ BMP280_STATUS_GET_CALIB
Definition: bmp280.h:66
@ BMP280_STATUS_UNINIT
Definition: bmp280.h:64
@ BMP280_STATUS_IDLE
Definition: bmp280.h:65
@ BMP280_STATUS_CONFIGURE
Definition: bmp280.h:67
enum bmp280_bus_t bus
The communication bus used to connect the device SPI/I2C.
Definition: bmp280.h:100
uint8_t rx_buf[50]
Definition: bmp280.h:48
enum bmp_device_t device
The device type detected.
Definition: bmp280.h:92
uint8_t tx_buf[50]
Transmit buffer.
Definition: bmp280.h:47
bmp_device_t
Definition: bmp280.h:57
@ BMP_UNKOWN
Definition: bmp280.h:58
@ BMP_280
Definition: bmp280.h:59
struct spi_transaction trans
Transaction used during configuration and measurements.
Definition: bmp280.h:45
void bmp280_event(struct bmp280_t *bmp)
Should be called in the event thread.
Definition: bmp280.c:157
uint16_t * rx_length
Definition: bmp280.h:107
float pressure
pressure in Pascal
Definition: bmp280.h:98
struct i2c_transaction trans
Transaction used during configuration and measurements.
Definition: bmp280.h:38
struct spi_periph * p
Peripheral device for communication.
Definition: bmp280.h:43
struct i2c_periph * p
Peripheral device for communication.
Definition: bmp280.h:37
uint8_t * rx_buffer
Definition: bmp280.h:105
bool initialized
config done flag
Definition: bmp280.h:93
uint32_t raw_pressure
uncompensated pressure
Definition: bmp280.h:96
I2C transaction structure.
Definition: i2c.h:93
SPI peripheral structure.
Definition: spi.h:174
SPI transaction structure.
Definition: spi.h:148
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
Architecture independent SPI (Serial Peripheral Interface) API.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98