Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
imu_umarim.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Gautier Hattenberger
3  * Derived from Aspirin and ppzuavimu drivers
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  */
23 
24 #include <math.h>
25 #include "imu_umarim.h"
26 #include "mcu_periph/i2c.h"
27 #include "led.h"
28 
29 // Downlink
30 #include "mcu_periph/uart.h"
31 #include "messages.h"
33 
34 #ifndef DOWNLINK_DEVICE
35 #define DOWNLINK_DEVICE DOWNLINK_AP_DEVICE
36 #endif
37 
38 // Peripherials
39 
40 // Configure ITG3200
41 // ITG3200_I2C_DEVICE IMU_UMARIM_I2C_DEVICE
42 // ITG3200_I2C_ADDR ITG3200_ADDR_ALT
43 // ITG3200_SMPLRT_DIV 19
44 // ITG3200_DLPF_CFG 4
46 
47 // Configure ADXL345
48 // ADXL345_I2C_DEVICE IMU_UMARIM_I2C_DEVICE
49 // ADXL345_I2C_ADDR ADXL345_ADDR_ALT
50 // ADXL345_BW_RATE 0x09 (50Hz rate, 25Hz BW)
52 
53 // Results
54 volatile bool_t gyr_valid;
55 volatile bool_t acc_valid;
56 
57 void imu_impl_init(void)
58 {
60  // ITG3200
61  itg3200_init();
62 
64  // ADXL345
65  adxl345_init();
66 
67 }
68 
69 void imu_periodic( void )
70 {
71  // Start reading the latest gyroscope data
73 
74  // Start reading the latest accelerometer data
76 
77  //RunOnceEvery(10,imu_umarim_downlink_raw());
78 }
79 
80 
82 {
85 }
86 
87 
88 void imu_umarim_event( void )
89 {
90 
91  // If the itg3200 I2C transaction has succeeded: convert the data
92  itg3200_event();
96  gyr_valid = TRUE;
97  }
98 
99  // If the adxl345 I2C transaction has succeeded: convert the data
100  adxl345_event();
102  // Be careful with orientation of the ADXL (ITG axes are taken as default reference)
105  acc_valid = TRUE;
106  }
107 
108 }
109 
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
void adxl345_event(void)
Definition: adxl345.i2c.c:116
void adxl345_init(void)
Definition: adxl345.i2c.c:49
int32_t p
in rad/s^2 with INT32_RATE_FRAC
void itg3200_init(void)
Definition: itg3200.c:49
#define Adxl345Periodic()
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:48
volatile bool_t itg3200_data_available
Definition: itg3200.c:38
struct Int16Vect3 adxl345_data
Definition: adxl345.i2c.c:40
volatile bool_t gyr_valid
Definition: imu_umarim.c:54
volatile bool_t acc_valid
Definition: imu_umarim.c:55
void imu_impl_init(void)
Definition: imu_umarim.c:57
#define FALSE
Definition: imu_chimu.h:141
void imu_periodic(void)
Definition: imu_umarim.c:69
void imu_umarim_downlink_raw(void)
Definition: imu_umarim.c:81
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:49
#define Itg3200Periodic()
Definition: itg3200.extra.h:85
volatile bool_t adxl345_data_available
Definition: adxl345.i2c.c:38
struct Int32Rates itg3200_data
Definition: itg3200.c:40
#define TRUE
Definition: imu_chimu.h:144
#define VECT3_ASSIGN(_a, _x, _y, _z)
Definition: pprz_algebra.h:99
#define RATES_ASSIGN(_ra, _p, _q, _r)
Definition: pprz_algebra.h:296
void imu_umarim_event(void)
Definition: imu_umarim.c:88
int32_t q
in rad/s^2 with INT32_RATE_FRAC
arch independent LED (Light Emitting Diodes) API
struct Imu imu
global IMU state
Definition: imu_aspirin2.c:50
int32_t r
in rad/s^2 with INT32_RATE_FRAC
void itg3200_event(void)
Definition: itg3200.c:116