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_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_t initialized;
43  volatile bool_t data_available;
44  struct Ms5611Data data;
46 };
47 
48 // Functions
49 extern void ms5611_spi_init(struct Ms5611_Spi* ms, struct spi_periph* spi_p, uint8_t addr);
50 extern void ms5611_spi_start_configure(struct Ms5611_Spi* ms);
51 extern void ms5611_spi_start_conversion(struct Ms5611_Spi* ms);
52 extern void ms5611_spi_periodic_check(struct Ms5611_Spi* ms);
53 extern void ms5611_spi_event(struct Ms5611_Spi* ms);
54 
59 static inline void ms5611_spi_read(struct Ms5611_Spi* ms) {
60  if (ms->initialized)
62  else
64 }
65 
67 static inline void ms5611_spi_periodic(struct Ms5611_Spi* ms) {
68  ms5611_spi_read(ms);
70 }
71 
72 
73 #endif /* MS5611_SPI_H */
struct spi_transaction spi_trans
Definition: ms5611_spi.h:38
void ms5611_spi_init(struct Ms5611_Spi *ms, struct spi_periph *spi_p, uint8_t addr)
Definition: ms5611_spi.c:33
struct Ms5611Data data
Definition: ms5611_spi.h:44
volatile uint8_t tx_buf[1]
Definition: ms5611_spi.h:39
static void ms5611_spi_read(struct Ms5611_Spi *ms)
convenience function to trigger new measurement.
Definition: ms5611_spi.h:59
void ms5611_spi_start_conversion(struct Ms5611_Spi *ms)
Definition: ms5611_spi.c:74
enum Ms5611Status status
Definition: ms5611_spi.h:41
struct spi_periph * spi_p
Definition: ms5611_spi.h:37
void ms5611_spi_event(struct Ms5611_Spi *ms)
Definition: ms5611_spi.c:131
int32_t prom_cnt
number of bytes read from PROM
Definition: ms5611_spi.h:45
volatile uint8_t rx_buf[4]
Definition: ms5611_spi.h:40
Architecture independent SPI (Serial Peripheral Interface) API.
volatile bool_t data_available
data ready flag
Definition: ms5611_spi.h:43
MS5611 barometer driver common interface (I2C and SPI).
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:90
Ms5611Status
Definition: ms5611.h:37
SPI peripheral structure.
Definition: spi.h:168
unsigned char uint8_t
Definition: types.h:14
bool_t initialized
config done flag
Definition: ms5611_spi.h:42
void ms5611_spi_start_configure(struct Ms5611_Spi *ms)
Definition: ms5611_spi.c:63
static void ms5611_spi_periodic(struct Ms5611_Spi *ms)
convenience function
Definition: ms5611_spi.h:67
SPI transaction structure.
Definition: spi.h:142