Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
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 #ifndef DOWNLINK_DEVICE
41 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
42 #endif
43 
44 #if !defined APOGEE_LOWPASS_FILTER && !defined APOGEE_SMPLRT_DIV
45 #define APOGEE_LOWPASS_FILTER MPU60X0_DLPF_42HZ
46 #define APOGEE_SMPLRT_DIV 9
47 PRINT_CONFIG_MSG("Gyro/Accel output rate is 100Hz")
48 #endif
49 PRINT_CONFIG_VAR(APOGEE_SMPLRT_DIV)
50 PRINT_CONFIG_VAR(APOGEE_LOWPASS_FILTER)
51 
52 #ifndef APOGEE_GYRO_RANGE
53 #define APOGEE_GYRO_RANGE MPU60X0_GYRO_RANGE_1000
54 #endif
55 PRINT_CONFIG_VAR(APOGEE_GYRO_RANGE)
56 
57 #ifndef APOGEE_ACCEL_RANGE
58 #define APOGEE_ACCEL_RANGE MPU60X0_ACCEL_RANGE_8G
59 #endif
60 PRINT_CONFIG_VAR(APOGEE_ACCEL_RANGE)
61 
63 
64 void imu_impl_init(void)
65 {
67  // MPU-60X0
68  mpu60x0_i2c_init(&imu_apogee.mpu, &(IMU_APOGEE_I2C_DEV), MPU60X0_ADDR_ALT);
69  // change the default configuration
74 
75  imu_apogee.gyr_valid = FALSE;
76  imu_apogee.acc_valid = FALSE;
77 }
78 
79 void imu_periodic( void )
80 {
81  // Start reading the latest gyroscope data
83 
84  //RunOnceEvery(10,imu_apogee_downlink_raw());
85 }
86 
88 {
91 }
92 
93 
94 void imu_apogee_event( void )
95 {
96  // If the itg3200 I2C transaction has succeeded: convert the data
104  }
105 }
106 
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^2 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
volatile bool_t acc_valid
Definition: imu_apogee.h:99
#define MPU60X0_ADDR_ALT
Definition: mpu60x0_regs.h:33
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:48
void imu_periodic(void)
Definition: imu_apogee.c:79
uint8_t smplrt_div
Sample rate divider.
Definition: mpu60x0.h:74
#define APOGEE_GYRO_RANGE
Definition: imu_apogee.c:53
union Mpu60x0_I2c::@23 data_accel
#define FALSE
Definition: imu_chimu.h:141
void imu_impl_init(void)
Definition: imu_apogee.c:64
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:49
enum Mpu60x0AccelRanges accel_range
g Range
Definition: mpu60x0.h:77
struct Imu imu
global IMU state
Definition: imu_aspirin2.c:50
#define APOGEE_LOWPASS_FILTER
Definition: imu_apogee.c:45
union Mpu60x0_I2c::@24 data_rates
void imu_apogee_event(void)
Definition: imu_apogee.c:94
enum Mpu60x0GyroRanges gyro_range
deg/s Range
Definition: mpu60x0.h:76
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:87
#define VECT3_ASSIGN(_a, _x, _y, _z)
Definition: pprz_algebra.h:97
struct Mpu60x0Config config
Definition: mpu60x0_i2c.h:67
#define RATES_ASSIGN(_ra, _p, _q, _r)
Definition: pprz_algebra.h:294
struct Int16Vect3 vect
accel data vector in accel coordinate system
Definition: mpu60x0_i2c.h:59
int32_t q
in rad/s^2 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:58
int32_t r
in rad/s^2 with INT32_RATE_FRAC
struct Mpu60x0_I2c mpu
Definition: imu_apogee.h:100
struct ImuApogee imu_apogee
Definition: imu_apogee.c:62
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:46