ms5611read.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  ms5611_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) (pressure*1000) % 1000,
48  (int32_t) temperature,
49  (int32_t) (temperature*1000) % 1000,
50  (int32_t) i2cGetErrorCounter());
51  }
52  else
53  {
56  printf("MS5611 unavailable\n");
57  }
58 
59 }
void setup(void)
Definition: ms5611read.c:26
uint16_t i2cGetErrorCounter(void)
Definition: drv_i2c.c:467
void i2cInit(I2CDevice index)
Definition: drv_i2c.c:420
float pressure
Definition: ms4525.c:41
float temperature
Definition: ms4525.c:41
bool ms5611_init()
Definition: drv_ms5611.c:151
static bool available
Definition: ms5611read.c:24
bool i2cWrite(uint8_t addr_, uint8_t reg_, uint8_t data)
Definition: drv_i2c.c:152
void loop(void)
Definition: ms5611read.c:38
void ms5611_async_update()
Definition: drv_ms5611.c:405
bool ms5611_present()
Definition: drv_ms5611.c:203
void ms5611_async_read(float *pressure, float *temperature)
Definition: drv_ms5611.c:452


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