Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures 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_t initialized;
41  volatile bool_t data_available;
42  struct Ms5611Data data;
44 };
45 
46 // Functions
47 extern void ms5611_i2c_init(struct Ms5611_I2c* ms, struct i2c_periph* i2c_p, uint8_t addr);
48 extern void ms5611_i2c_start_configure(struct Ms5611_I2c* ms);
49 extern void ms5611_i2c_start_conversion(struct Ms5611_I2c* ms);
50 extern void ms5611_i2c_periodic_check(struct Ms5611_I2c* ms);
51 extern void ms5611_i2c_event(struct Ms5611_I2c* ms);
52 
57 static inline void ms5611_i2c_read(struct Ms5611_I2c* ms) {
58  if (ms->initialized)
60  else
62 }
63 
65 static inline void ms5611_i2c_periodic(struct Ms5611_I2c* ms) {
66  ms5611_i2c_read(ms);
68 }
69 
70 
71 #endif /* MS5611_I2C_H */
void ms5611_i2c_start_configure(struct Ms5611_I2c *ms)
Definition: ms5611_i2c.c:49
I2C transaction structure.
Definition: i2c.h:93
volatile bool_t data_available
data ready flag
Definition: ms5611_i2c.h:41
struct i2c_transaction i2c_trans
Definition: ms5611_i2c.h:38
struct Ms5611Data data
Definition: ms5611_i2c.h:42
MS5611 barometer driver common interface (I2C and SPI).
void ms5611_i2c_start_conversion(struct Ms5611_I2c *ms)
Definition: ms5611_i2c.c:60
void ms5611_i2c_periodic_check(struct Ms5611_I2c *ms)
Periodic function to ensure proper delay after triggering reset or conversion.
Definition: ms5611_i2c.c:76
static void ms5611_i2c_periodic(struct Ms5611_I2c *ms)
convenience function
Definition: ms5611_i2c.h:65
void ms5611_i2c_init(struct Ms5611_I2c *ms, struct i2c_periph *i2c_p, uint8_t addr)
Definition: ms5611_i2c.c:33
signed long int32_t
Definition: types.h:19
Ms5611Status
Definition: ms5611.h:37
unsigned char uint8_t
Definition: types.h:14
I2C peripheral structure.
Definition: i2c.h:138
void ms5611_i2c_event(struct Ms5611_I2c *ms)
Definition: ms5611_i2c.c:117
bool_t initialized
config done flag
Definition: ms5611_i2c.h:40
struct i2c_periph * i2c_p
Definition: ms5611_i2c.h:37
static void ms5611_i2c_read(struct Ms5611_I2c *ms)
convenience function to trigger new measurement.
Definition: ms5611_i2c.h:57
int32_t prom_cnt
number of bytes read from PROM
Definition: ms5611_i2c.h:43
enum Ms5611Status status
Definition: ms5611_i2c.h:39
Architecture independent I2C (Inter-Integrated Circuit Bus) API.