Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
lps25h_i2c.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Alexis Cornard <alexiscornard@gmail.com>
3  *
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, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
28 #ifndef LPS25H_I2C_H
29 #define LPS25H_I2C_H
30 
31 #include "std.h"
32 #include "math/pprz_algebra_int.h"
33 #include "mcu_periph/i2c.h"
34 
35 /* Include common LPS25H options and definitions */
36 #include "peripherals/lps25h.h"
37 
38 struct Lps25h_I2c {
39  struct i2c_periph *i2c_p;
42  bool initialized;
43  volatile bool data_available;
46 };
47 
48 // Functions
49 extern void lps25h_i2c_init(struct Lps25h_I2c *lps, struct i2c_periph *i2c_p, uint8_t addr);
50 extern void lps25h_i2c_start_configure(struct Lps25h_I2c *lps);
51 extern void lps25h_i2c_read(struct Lps25h_I2c *lps);
52 extern void lps25h_i2c_event(struct Lps25h_I2c *lps);
53 extern float lps25h_readPressureMillibars(int32_t press);
54 extern float pressureToAltMeters(float pressure_mbar, float altimeter_setting_mbar);
55 
56 // convenience function: read or start configuration if not already initialized
57 static inline void lps25h_i2c_periodic(struct Lps25h_I2c *lps)
58 {
59  if (lps->initialized) {
60  lps25h_i2c_read(lps);
61  } else {
63  }
64 }
65 
66 #endif // LPS25H_I2C_H
Lps25hConfig
Definition: lps25h.h:42
lps25h_i2c_start_configure
void lps25h_i2c_start_configure(struct Lps25h_I2c *lps)
Definition: lps25h_i2c.c:76
Lps25h_I2c::initialized
bool initialized
config done flag
Definition: lps25h_i2c.h:42
Lps25h_I2c::data_available
volatile bool data_available
data ready flag
Definition: lps25h_i2c.h:43
pressureToAltMeters
float pressureToAltMeters(float pressure_mbar, float altimeter_setting_mbar)
Definition: lps25h_i2c.c:106
pprz_algebra_int.h
Paparazzi fixed point algebra.
std.h
Lps25h_I2c::init_status
enum Lps25hConfStatus init_status
init status
Definition: lps25h_i2c.h:41
lps25h_i2c_init
void lps25h_i2c_init(struct Lps25h_I2c *lps, struct i2c_periph *i2c_p, uint8_t addr)
Definition: lps25h_i2c.c:33
lps25h.h
Lps25hConfStatus
Lps25hConfStatus
Definition: lps25h.h:36
Lps25h_I2c::i2c_trans
struct i2c_transaction i2c_trans
Definition: lps25h_i2c.h:40
uint8_t
unsigned char uint8_t
Definition: types.h:14
Lps25h_I2c::data
int32_t data
Definition: lps25h_i2c.h:44
lps25h_i2c_event
void lps25h_i2c_event(struct Lps25h_I2c *lps)
Definition: lps25h_i2c.c:110
lps25h_i2c_periodic
static void lps25h_i2c_periodic(struct Lps25h_I2c *lps)
Definition: lps25h_i2c.h:57
i2c_transaction
I2C transaction structure.
Definition: i2c.h:93
lps25h_readPressureMillibars
float lps25h_readPressureMillibars(int32_t press)
Definition: lps25h_i2c.c:101
Lps25h_I2c::config
struct Lps25hConfig config
Definition: lps25h_i2c.h:45
Lps25h_I2c::i2c_p
struct i2c_periph * i2c_p
Definition: lps25h_i2c.h:39
int32_t
signed long int32_t
Definition: types.h:19
i2c_periph
Definition: i2c.h:144
i2c.h
Lps25h_I2c
Definition: lps25h_i2c.h:38
lps25h_i2c_read
void lps25h_i2c_read(struct Lps25h_I2c *lps)
Definition: lps25h_i2c.c:87