Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 */
Ms5611_Spi::status
enum Ms5611Status status
Definition: ms5611_spi.h:41
ms5611_spi_periodic_check
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
Ms5611_Spi::is_ms5607
bool is_ms5607
TRUE if MS5607, FALSE if MS5611.
Definition: ms5611_spi.h:42
ms5611.h
spi.h
spi_transaction
SPI transaction structure.
Definition: spi.h:148
ms5611_spi_read
static void ms5611_spi_read(struct Ms5611_Spi *ms)
convenience function to trigger new measurement.
Definition: ms5611_spi.h:61
Ms5611_Spi::rx_buf
volatile uint8_t rx_buf[4]
Definition: ms5611_spi.h:40
Ms5611_Spi
Definition: ms5611_spi.h:36
Ms5611_Spi::data_available
volatile bool data_available
data ready flag
Definition: ms5611_spi.h:44
spi_periph
SPI peripheral structure.
Definition: spi.h:174
Ms5611Data
Definition: ms5611.h:51
Ms5611_Spi::prom_cnt
int32_t prom_cnt
number of bytes read from PROM
Definition: ms5611_spi.h:46
Ms5611_Spi::initialized
bool initialized
config done flag
Definition: ms5611_spi.h:43
uint8_t
unsigned char uint8_t
Definition: types.h:14
Ms5611_Spi::spi_p
struct spi_periph * spi_p
Definition: ms5611_spi.h:37
ms5611_spi_periodic
static void ms5611_spi_periodic(struct Ms5611_Spi *ms)
convenience function
Definition: ms5611_spi.h:71
Ms5611Status
Ms5611Status
Definition: ms5611.h:37
Ms5611_Spi::spi_trans
struct spi_transaction spi_trans
Definition: ms5611_spi.h:38
int32_t
signed long int32_t
Definition: types.h:19
ms5611_spi_start_conversion
void ms5611_spi_start_conversion(struct Ms5611_Spi *ms)
Definition: ms5611_spi.c:76
ms5611_spi_event
void ms5611_spi_event(struct Ms5611_Spi *ms)
Definition: ms5611_spi.c:133
ms5611_spi_init
void ms5611_spi_init(struct Ms5611_Spi *ms, struct spi_periph *spi_p, uint8_t addr, bool is_ms5607)
Definition: ms5611_spi.c:33
ms5611_spi_start_configure
void ms5611_spi_start_configure(struct Ms5611_Spi *ms)
Definition: ms5611_spi.c:65
Ms5611_Spi::data
struct Ms5611Data data
Definition: ms5611_spi.h:45
Ms5611_Spi::tx_buf
volatile uint8_t tx_buf[1]
Definition: ms5611_spi.h:39