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
imu_apogee.c
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 
30 #include <math.h>
32 #include "mcu_periph/i2c.h"
33 #include "led.h"
34 
35 // Downlink
36 #include "mcu_periph/uart.h"
37 #include "messages.h"
39 
40 
41 #if !defined APOGEE_LOWPASS_FILTER && !defined APOGEE_SMPLRT_DIV
42 #define APOGEE_LOWPASS_FILTER MPU60X0_DLPF_42HZ
43 #define APOGEE_SMPLRT_DIV 9
44 PRINT_CONFIG_MSG("Gyro/Accel output rate is 100Hz")
45 #endif
48 
49 #ifndef APOGEE_GYRO_RANGE
50 #define APOGEE_GYRO_RANGE MPU60X0_GYRO_RANGE_1000
51 #endif
53 
54 #ifndef APOGEE_ACCEL_RANGE
55 #define APOGEE_ACCEL_RANGE MPU60X0_ACCEL_RANGE_8G
56 #endif
58 
60 
61 // baro config will be done later in bypass mode
62 bool_t configure_baro_slave(Mpu60x0ConfigSet mpu_set, void* mpu);
63 
64 bool_t configure_baro_slave(Mpu60x0ConfigSet mpu_set __attribute__ ((unused)), void* mpu __attribute__ ((unused))) {
65  return TRUE;
66 }
67 
68 void imu_impl_init(void)
69 {
71  // MPU-60X0
72  mpu60x0_i2c_init(&imu_apogee.mpu, &(IMU_APOGEE_I2C_DEV), MPU60X0_ADDR_ALT);
73  // change the default configuration
78  // set MPU in bypass mode for the baro
82 
85 }
86 
87 void imu_periodic( void )
88 {
89  // Start reading the latest gyroscope data
91 
92  //RunOnceEvery(10,imu_apogee_downlink_raw());
93 }
94 
96 {
99 }
100 
101 
102 void imu_apogee_event( void )
103 {
104  // If the itg3200 I2C transaction has succeeded: convert the data
112  }
113 }
114 
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
Driver for the IMU on the Apogee board.
void mpu60x0_i2c_event(struct Mpu60x0_I2c *mpu)
Definition: mpu60x0_i2c.c:81
enum Mpu60x0DLPF dlpf_cfg
Digital Low Pass Filter.
Definition: mpu60x0.h:75
int32_t p
in rad/s with INT32_RATE_FRAC
void mpu60x0_i2c_init(struct Mpu60x0_I2c *mpu, struct i2c_periph *i2c_p, uint8_t addr)
Definition: mpu60x0_i2c.c:31
bool_t configure_baro_slave(Mpu60x0ConfigSet mpu_set, void *mpu)
Definition: imu_apogee.c:64
volatile bool_t acc_valid
Definition: imu_apogee.h:99
#define MPU60X0_ADDR_ALT
Definition: mpu60x0_regs.h:33
uint8_t nb_slaves
number of used I2C slaves
Definition: mpu60x0.h:89
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:49
void imu_periodic(void)
Definition: imu_apogee.c:87
union Mpu60x0_I2c::@38 data_rates
uint8_t smplrt_div
Sample rate divider.
Definition: mpu60x0.h:74
#define APOGEE_GYRO_RANGE
Definition: imu_apogee.c:50
#define FALSE
Definition: imu_chimu.h:141
Mpu60x0I2cSlaveConfigure configure
Definition: mpu60x0.h:70
void imu_impl_init(void)
Definition: imu_apogee.c:68
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:50
enum Mpu60x0AccelRanges accel_range
g Range
Definition: mpu60x0.h:77
struct Imu imu
global IMU state
Definition: imu_aspirin2.c:47
#define APOGEE_LOWPASS_FILTER
Definition: imu_apogee.c:42
void imu_apogee_event(void)
Definition: imu_apogee.c:102
enum Mpu60x0GyroRanges gyro_range
deg/s Range
Definition: mpu60x0.h:76
struct Mpu60x0I2cSlave slaves[5]
I2C slaves.
Definition: mpu60x0.h:90
volatile bool_t data_available
data ready flag
Definition: mpu60x0_i2c.h:57
struct Int16Rates rates
rates data as angular rates in gyro coordinate system
Definition: mpu60x0_i2c.h:63
#define TRUE
Definition: imu_chimu.h:144
void imu_apogee_downlink_raw(void)
Definition: imu_apogee.c:95
#define VECT3_ASSIGN(_a, _x, _y, _z)
Definition: pprz_algebra.h:107
struct Mpu60x0Config config
Definition: mpu60x0_i2c.h:67
bool_t i2c_bypass
Bypass MPU I2C.
Definition: mpu60x0.h:87
#define RATES_ASSIGN(_ra, _p, _q, _r)
Definition: pprz_algebra.h:319
struct Int16Vect3 vect
accel data vector in accel coordinate system
Definition: mpu60x0_i2c.h:59
int32_t q
in rad/s with INT32_RATE_FRAC
arch independent LED (Light Emitting Diodes) API
static void mpu60x0_i2c_periodic(struct Mpu60x0_I2c *mpu)
convenience function: read or start configuration if not already initialized
Definition: mpu60x0_i2c.h:78
#define APOGEE_ACCEL_RANGE
Definition: imu_apogee.c:55
int32_t r
in rad/s with INT32_RATE_FRAC
union Mpu60x0_I2c::@37 data_accel
struct Mpu60x0_I2c mpu
Definition: imu_apogee.h:100
void(* Mpu60x0ConfigSet)(void *mpu, uint8_t _reg, uint8_t _val)
Configuration function prototype.
Definition: mpu60x0.h:64
struct ImuApogee imu_apogee
Definition: imu_apogee.c:59
volatile bool_t gyr_valid
Definition: imu_apogee.h:98
Architecture independent I2C (Inter-Integrated Circuit Bus) API.
#define APOGEE_SMPLRT_DIV
Definition: imu_apogee.c:43