Paparazzi UAS  v5.15_devel-113-g1b57ff1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ms5611_i2c.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Felix Ruess <felix.ruess@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 MS5611_I2C_H
29 #define MS5611_I2C_H
30 
31 #include "mcu_periph/i2c.h"
32 
33 /* Include common MS5611 definitions */
34 #include "peripherals/ms5611.h"
35 
36 struct Ms5611_I2c {
37  struct i2c_periph *i2c_p;
40  bool is_ms5607;
41  bool initialized;
42  volatile bool data_available;
43  struct Ms5611Data data;
45 };
46 
47 // Functions
48 extern void ms5611_i2c_init(struct Ms5611_I2c *ms, struct i2c_periph *i2c_p, uint8_t addr,
49  bool is_ms5607);
50 extern void ms5611_i2c_start_configure(struct Ms5611_I2c *ms);
51 extern void ms5611_i2c_start_conversion(struct Ms5611_I2c *ms);
52 extern void ms5611_i2c_periodic_check(struct Ms5611_I2c *ms);
53 extern void ms5611_i2c_event(struct Ms5611_I2c *ms);
54 
59 static inline void ms5611_i2c_read(struct Ms5611_I2c *ms)
60 {
61  if (ms->initialized) {
63  } else {
65  }
66 }
67 
69 static inline void ms5611_i2c_periodic(struct Ms5611_I2c *ms)
70 {
71  ms5611_i2c_read(ms);
73 }
74 
75 
76 #endif /* MS5611_I2C_H */
void ms5611_i2c_start_configure(struct Ms5611_I2c *ms)
Definition: ms5611_i2c.c:51
struct Ms5611Data data
Definition: ms5611_i2c.h:43
bool is_ms5607
TRUE if MS5607, FALSE if MS5611.
Definition: ms5611_i2c.h:40
int32_t prom_cnt
number of bytes read from PROM
Definition: ms5611_i2c.h:44
MS5611 barometer driver common interface (I2C and SPI).
void ms5611_i2c_start_conversion(struct Ms5611_I2c *ms)
Definition: ms5611_i2c.c:62
volatile bool data_available
data ready flag
Definition: ms5611_i2c.h:42
void ms5611_i2c_periodic_check(struct Ms5611_I2c *ms)
Periodic function to ensure proper delay after triggering reset or conversion.
Definition: ms5611_i2c.c:78
static void ms5611_i2c_periodic(struct Ms5611_I2c *ms)
convenience function
Definition: ms5611_i2c.h:69
enum Ms5611Status status
Definition: ms5611_i2c.h:39
I2C transaction structure.
Definition: i2c.h:93
signed long int32_t
Definition: types.h:19
Ms5611Status
Definition: ms5611.h:37
I2C peripheral structure.
Definition: i2c.h:138
unsigned char uint8_t
Definition: types.h:14
struct i2c_transaction i2c_trans
Definition: ms5611_i2c.h:38
bool initialized
config done flag
Definition: ms5611_i2c.h:41
struct i2c_periph * i2c_p
Definition: ms5611_i2c.h:37
void ms5611_i2c_event(struct Ms5611_I2c *ms)
Definition: ms5611_i2c.c:119
void ms5611_i2c_init(struct Ms5611_I2c *ms, struct i2c_periph *i2c_p, uint8_t addr, bool is_ms5607)
Definition: ms5611_i2c.c:33
static void ms5611_i2c_read(struct Ms5611_I2c *ms)
convenience function to trigger new measurement.
Definition: ms5611_i2c.h:59
Architecture independent I2C (Inter-Integrated Circuit Bus) API.