bmp280read.c
Go to the documentation of this file.
1 /*
2  ms5611read.c : read values from MS5611 barometer using I^2C
3 
4  Copyright (C) 2016 Simon D. Levy
5 
6  This file is part of BreezySTM32.
7 
8  BreezySTM32 is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  BreezySTM32 is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with BreezySTM32. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <breezystm32.h>
23 
24 static bool available;
25 
26 void setup(void)
27 {
28  // Get particulars for board
30 
31  // Not sure why the ms5611 needs this, but without this line it doesn't work
32  i2cWrite(0,0,0);
33 
34  // attempt to initialize barometer
36 }
37 
38 void loop(void)
39 {
40 
41  float pressure, temperature;
42  if (available) {
44  bmp280_async_read(&pressure, &temperature);
45  printf("Pressure: %d.%d Pa\tTemperature: %d.%d K, i2c_errors: %d\n",
46  (int32_t) pressure,
47  (int32_t) abs(pressure*1000) % 1000,
48  (int32_t) temperature,
49  (int32_t) abs(temperature*1000) % 1000,
50  (int32_t) i2cGetErrorCounter());
51  }
52  else
53  {
56  printf("bmp280 unavailable\n");
57  }
58 
59 }
uint16_t i2cGetErrorCounter(void)
Definition: drv_i2c.c:467
void i2cInit(I2CDevice index)
Definition: drv_i2c.c:420
void loop(void)
Definition: bmp280read.c:38
float pressure
Definition: ms4525.c:41
float temperature
Definition: ms4525.c:41
static double abs(double a)
Definition: printf.cpp:42
bool i2cWrite(uint8_t addr_, uint8_t reg_, uint8_t data)
Definition: drv_i2c.c:152
void bmp280_async_read(float *pres, float *temp)
Definition: drv_bmp280.c:180
static bool available
Definition: bmp280read.c:24
bool bmp280_init()
Definition: drv_bmp280.c:69
void setup(void)
Definition: bmp280read.c:26
bool bmp280_present()
Definition: drv_bmp280.c:64
void bmp280_async_update()
Definition: drv_bmp280.c:163


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:46