Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ms5611_spi.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_SPI_H
29 #define MS5611_SPI_H
30 
31 #include "mcu_periph/spi.h"
32 
33 /* Include common MS5611 definitions */
34 #include "peripherals/ms5611.h"
35 
36 struct Ms5611_Spi {
37  struct spi_periph *spi_p;
39  volatile uint8_t tx_buf[1];
40  volatile uint8_t rx_buf[4];
42  bool is_ms5607;
43  bool initialized;
44  volatile bool data_available;
45  struct Ms5611Data data;
47 };
48 
49 // Functions
50 extern void ms5611_spi_init(struct Ms5611_Spi *ms, struct spi_periph *spi_p, uint8_t addr,
51  bool is_ms5607);
52 extern void ms5611_spi_start_configure(struct Ms5611_Spi *ms);
53 extern void ms5611_spi_start_conversion(struct Ms5611_Spi *ms);
54 extern void ms5611_spi_periodic_check(struct Ms5611_Spi *ms);
55 extern void ms5611_spi_event(struct Ms5611_Spi *ms);
56 
61 static inline void ms5611_spi_read(struct Ms5611_Spi *ms)
62 {
63  if (ms->initialized) {
65  } else {
67  }
68 }
69 
71 static inline void ms5611_spi_periodic(struct Ms5611_Spi *ms)
72 {
73  ms5611_spi_read(ms);
75 }
76 
77 
78 #endif /* MS5611_SPI_H */
void ms5611_spi_init(struct Ms5611_Spi *ms, struct spi_periph *spi_p, uint8_t addr, bool is_ms5607)
Definition: ms5611_spi.c:33
volatile bool data_available
data ready flag
Definition: ms5611_spi.h:44
volatile uint8_t rx_buf[4]
Definition: ms5611_spi.h:40
struct Ms5611Data data
Definition: ms5611_spi.h:45
static void ms5611_spi_read(struct Ms5611_Spi *ms)
convenience function to trigger new measurement.
Definition: ms5611_spi.h:61
volatile uint8_t tx_buf[1]
Definition: ms5611_spi.h:39
void ms5611_spi_start_conversion(struct Ms5611_Spi *ms)
Definition: ms5611_spi.c:76
SPI transaction structure.
Definition: spi.h:148
void ms5611_spi_event(struct Ms5611_Spi *ms)
Definition: ms5611_spi.c:133
Architecture independent SPI (Serial Peripheral Interface) API.
SPI peripheral structure.
Definition: spi.h:174
MS5611 barometer driver common interface (I2C and SPI).
struct spi_periph * spi_p
Definition: ms5611_spi.h:37
int32_t prom_cnt
number of bytes read from PROM
Definition: ms5611_spi.h:46
bool initialized
config done flag
Definition: ms5611_spi.h:43
signed long int32_t
Definition: types.h:19
void ms5611_spi_periodic_check(struct Ms5611_Spi *ms)
Periodic function to ensure proper delay after triggering reset or conversion.
Definition: ms5611_spi.c:92
Ms5611Status
Definition: ms5611.h:37
bool is_ms5607
TRUE if MS5607, FALSE if MS5611.
Definition: ms5611_spi.h:42
struct spi_transaction spi_trans
Definition: ms5611_spi.h:38
enum Ms5611Status status
Definition: ms5611_spi.h:41
unsigned char uint8_t
Definition: types.h:14
void ms5611_spi_start_configure(struct Ms5611_Spi *ms)
Definition: ms5611_spi.c:65
static void ms5611_spi_periodic(struct Ms5611_Spi *ms)
convenience function
Definition: ms5611_spi.h:71