Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
adxl345_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 ADXL345_SPI_H
29 #define ADXL345_SPI_H
30 
31 #include "std.h"
32 #include "math/pprz_algebra_int.h"
33 #include "mcu_periph/spi.h"
34 
35 /* Include common ADXL345 options and definitions */
36 #include "peripherals/adxl345.h"
37 
38 
39 struct Adxl345_Spi {
40  struct spi_periph *spi_p;
42  volatile uint8_t tx_buf[7];
43  volatile uint8_t rx_buf[7];
45  bool initialized;
46  volatile bool data_available;
47  union {
48  struct Int16Vect3 vect;
49  int16_t value[3];
50  } data;
52 };
53 
54 // Functions
55 extern void adxl345_spi_init(struct Adxl345_Spi *adxl, struct spi_periph *spi_p, uint8_t addr);
56 extern void adxl345_spi_start_configure(struct Adxl345_Spi *adxl);
57 extern void adxl345_spi_read(struct Adxl345_Spi *adxl);
58 extern void adxl345_spi_event(struct Adxl345_Spi *adxl);
59 
61 static inline void adxl345_spi_periodic(struct Adxl345_Spi *adxl)
62 {
63  if (adxl->initialized) {
64  adxl345_spi_read(adxl);
65  } else {
67  }
68 }
69 
70 #endif // ADXL345_SPI_H
Int16Vect3
Definition: pprz_algebra_int.h:62
spi.h
spi_transaction
SPI transaction structure.
Definition: spi.h:148
Adxl345_Spi::init_status
enum Adxl345ConfStatus init_status
init status
Definition: adxl345_spi.h:44
Adxl345_Spi
Definition: adxl345_spi.h:39
Adxl345_Spi::rx_buf
volatile uint8_t rx_buf[7]
Definition: adxl345_spi.h:43
Adxl345_Spi::spi_trans
struct spi_transaction spi_trans
Definition: adxl345_spi.h:41
Adxl345_Spi::data_available
volatile bool data_available
data ready flag
Definition: adxl345_spi.h:46
pprz_algebra_int.h
Paparazzi fixed point algebra.
adxl345_spi_event
void adxl345_spi_event(struct Adxl345_Spi *adxl)
Definition: adxl345_spi.c:131
spi_periph
SPI peripheral structure.
Definition: spi.h:174
adxl345.h
std.h
int16_t
signed short int16_t
Definition: types.h:17
Adxl345_Spi::spi_p
struct spi_periph * spi_p
Definition: adxl345_spi.h:40
uint8_t
unsigned char uint8_t
Definition: types.h:14
adxl345_spi_read
void adxl345_spi_read(struct Adxl345_Spi *adxl)
Definition: adxl345_spi.c:118
adxl345_spi_start_configure
void adxl345_spi_start_configure(struct Adxl345_Spi *adxl)
Definition: adxl345_spi.c:108
Adxl345_Spi::data
union Adxl345_Spi::@305 data
Adxl345ConfStatus
Adxl345ConfStatus
Definition: adxl345.h:36
adxl345_spi_periodic
static void adxl345_spi_periodic(struct Adxl345_Spi *adxl)
convenience function: read or start configuration if not already initialized
Definition: adxl345_spi.h:61
adxl345_spi_init
void adxl345_spi_init(struct Adxl345_Spi *adxl, struct spi_periph *spi_p, uint8_t addr)
Definition: adxl345_spi.c:35
Adxl345_Spi::tx_buf
volatile uint8_t tx_buf[7]
Definition: adxl345_spi.h:42
Adxl345_Spi::config
struct Adxl345Config config
Definition: adxl345_spi.h:51
Adxl345_Spi::initialized
bool initialized
config done flag
Definition: adxl345_spi.h:45
Adxl345Config
Definition: adxl345.h:45