Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
mpu60x0_spi.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Gautier Hattenberger
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 MPU60X0_SPI_H
29 #define MPU60X0_SPI_H
30 
31 #include "std.h"
32 #include "math/pprz_algebra_int.h"
33 #include "mcu_periph/spi.h"
34 
35 /* Include common MPU60X0 options and definitions */
36 #include "peripherals/mpu60x0.h"
37 
38 
39 #define MPU60X0_BUFFER_LEN 32
40 #define MPU60X0_BUFFER_EXT_LEN 16
41 
49 };
50 
51 struct Mpu60x0_Spi {
52  struct spi_periph *spi_p;
54  volatile uint8_t tx_buf[2];
56  volatile bool data_available;
57  union {
58  struct Int16Vect3 vect;
59  int16_t value[3];
61  union {
62  struct Int16Rates rates;
63  int16_t value[3];
65  float temp;
67  struct Mpu60x0Config config;
69 };
70 
71 // Functions
72 extern void mpu60x0_spi_init(struct Mpu60x0_Spi *mpu, struct spi_periph *spi_p, uint8_t addr);
73 extern void mpu60x0_spi_start_configure(struct Mpu60x0_Spi *mpu);
74 extern void mpu60x0_spi_read(struct Mpu60x0_Spi *mpu);
75 extern void mpu60x0_spi_event(struct Mpu60x0_Spi *mpu);
76 
78 static inline void mpu60x0_spi_periodic(struct Mpu60x0_Spi *mpu)
79 {
80  if (mpu->config.initialized) {
81  mpu60x0_spi_read(mpu);
82  } else {
84  }
85 }
86 
87 #endif // MPU60X0_SPI_H
SPI peripheral structure.
Definition: spi.h:174
SPI transaction structure.
Definition: spi.h:148
MPU-60X0 driver common interface (I2C and SPI).
bool initialized
config done flag
Definition: mpu60x0.h:149
volatile bool data_available
data ready flag
Definition: mpu60x0_spi.h:56
uint8_t data_ext[MPU60X0_BUFFER_EXT_LEN]
Definition: mpu60x0_spi.h:66
void mpu60x0_spi_read(struct Mpu60x0_Spi *mpu)
Definition: mpu60x0_spi.c:115
struct Mpu60x0Config config
Definition: mpu60x0_spi.h:67
void mpu60x0_spi_event(struct Mpu60x0_Spi *mpu)
Definition: mpu60x0_spi.c:128
struct spi_transaction spi_trans
Definition: mpu60x0_spi.h:53
float temp
temperature in degrees Celcius
Definition: mpu60x0_spi.h:65
union Mpu60x0_Spi::@342 data_rates
volatile uint8_t tx_buf[2]
Definition: mpu60x0_spi.h:54
#define MPU60X0_BUFFER_EXT_LEN
Definition: mpu60x0_spi.h:40
void mpu60x0_spi_start_configure(struct Mpu60x0_Spi *mpu)
Definition: mpu60x0_spi.c:77
enum Mpu60x0SpiSlaveInitStatus slave_init_status
Definition: mpu60x0_spi.h:68
struct spi_periph * spi_p
Definition: mpu60x0_spi.h:52
Mpu60x0SpiSlaveInitStatus
Definition: mpu60x0_spi.h:42
@ MPU60X0_SPI_CONF_SLAVES_CONFIGURE
Definition: mpu60x0_spi.h:47
@ MPU60X0_SPI_CONF_UNINIT
Definition: mpu60x0_spi.h:43
@ MPU60X0_SPI_CONF_I2C_MST_CLK
Definition: mpu60x0_spi.h:44
@ MPU60X0_SPI_CONF_DONE
Definition: mpu60x0_spi.h:48
@ MPU60X0_SPI_CONF_I2C_MST_DELAY
Definition: mpu60x0_spi.h:45
@ MPU60X0_SPI_CONF_I2C_MST_EN
Definition: mpu60x0_spi.h:46
volatile uint8_t rx_buf[MPU60X0_BUFFER_LEN]
Definition: mpu60x0_spi.h:55
static void mpu60x0_spi_periodic(struct Mpu60x0_Spi *mpu)
convenience function: read or start configuration if not already initialized
Definition: mpu60x0_spi.h:78
#define MPU60X0_BUFFER_LEN
Definition: mpu60x0_spi.h:39
union Mpu60x0_Spi::@341 data_accel
void mpu60x0_spi_init(struct Mpu60x0_Spi *mpu, struct spi_periph *spi_p, uint8_t addr)
Definition: mpu60x0_spi.c:31
Paparazzi fixed point algebra.
Architecture independent SPI (Serial Peripheral Interface) API.
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98