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
lis302dl_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 LIS302DL_SPI_H
29 #define LIS302DL_SPI_H
30 
31 #include "std.h"
32 #include "math/pprz_algebra_int.h"
33 #include "mcu_periph/spi.h"
34 
35 /* Include common LIS302DL options and definitions */
36 #include "peripherals/lis302dl.h"
37 
38 
39 struct Lis302dl_Spi {
40  struct spi_periph *spi_p;
42  volatile uint8_t tx_buf[2];
43  volatile uint8_t rx_buf[8];
45  bool_t initialized;
46  volatile bool_t data_available;
47  union {
48  struct Int8Vect3 vect;
50  } data;
52 };
53 
54 // Functions
55 extern void lis302dl_spi_init(struct Lis302dl_Spi *lis, struct spi_periph *spi_p, uint8_t addr);
56 extern void lis302dl_spi_start_configure(struct Lis302dl_Spi *lis);
57 extern void lis302dl_spi_read(struct Lis302dl_Spi *lis);
58 extern void lis302dl_spi_event(struct Lis302dl_Spi *lis);
59 
61 static inline void lis302dl_spi_periodic(struct Lis302dl_Spi *lis) {
62  if (lis->initialized)
63  lis302dl_spi_read(lis);
64  else
66 }
67 
68 #endif // LIS302DL_SPI_H
void lis302dl_spi_event(struct Lis302dl_Spi *lis)
Definition: lis302dl_spi.c:137
Lis302dlConfStatus
Definition: lis302dl.h:34
volatile uint8_t tx_buf[2]
Definition: lis302dl_spi.h:42
enum Lis302dlConfStatus init_status
init status
Definition: lis302dl_spi.h:44
union Lis302dl_Spi::@33 data
Architecture independent SPI (Serial Peripheral Interface) API.
struct spi_transaction spi_trans
Definition: lis302dl_spi.h:41
void lis302dl_spi_read(struct Lis302dl_Spi *lis)
Definition: lis302dl_spi.c:126
static void lis302dl_spi_periodic(struct Lis302dl_Spi *lis)
convenience function: read or start configuration if not already initialized
Definition: lis302dl_spi.h:61
volatile uint8_t rx_buf[8]
Definition: lis302dl_spi.h:43
volatile bool_t data_available
data ready flag
Definition: lis302dl_spi.h:46
void lis302dl_spi_init(struct Lis302dl_Spi *lis, struct spi_periph *spi_p, uint8_t addr)
Definition: lis302dl_spi.c:30
SPI peripheral structure.
Definition: spi.h:168
void lis302dl_spi_start_configure(struct Lis302dl_Spi *lis)
Definition: lis302dl_spi.c:116
unsigned char uint8_t
Definition: types.h:14
struct Lis302dlConfig config
Definition: lis302dl_spi.h:51
bool_t initialized
config done flag
Definition: lis302dl_spi.h:45
SPI transaction structure.
Definition: spi.h:142
struct Int8Vect3 vect
data vector in accel coordinate system
Definition: lis302dl_spi.h:48
signed char int8_t
Definition: types.h:15
int8_t value[3]
data values accessible by channel index
Definition: lis302dl_spi.h:49
ST LIS302DL 3-axis accelerometer driver common interface (I2C and SPI).
struct spi_periph * spi_p
Definition: lis302dl_spi.h:40
Paparazzi fixed point algebra.