Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
imu_crista.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
24 #ifndef IMU_CRISTA_H
25 #define IMU_CRISTA_H
26 
27 #include "subsystems/imu.h"
28 #include "generated/airframe.h"
29 
30 #define ADS8344_NB_CHANNELS 8
32 extern volatile bool_t ADS8344_available;
33 
34 #define ImuEvent(_gyro_handler, _accel_handler, _mag_handler) { \
35  if (ADS8344_available) { \
36  ADS8344_available = FALSE; \
37  imu.gyro_unscaled.p = ADS8344_values[IMU_GYRO_P_CHAN]; \
38  imu.gyro_unscaled.q = ADS8344_values[IMU_GYRO_Q_CHAN]; \
39  imu.gyro_unscaled.r = ADS8344_values[IMU_GYRO_R_CHAN]; \
40  imu.accel_unscaled.x = ADS8344_values[IMU_ACCEL_X_CHAN]; \
41  imu.accel_unscaled.y = ADS8344_values[IMU_ACCEL_Y_CHAN]; \
42  imu.accel_unscaled.z = ADS8344_values[IMU_ACCEL_Z_CHAN]; \
43  /* spare 3, temp 7 */ \
44  _gyro_handler(); \
45  _accel_handler(); \
46  } \
47  ImuMagEvent(_mag_handler); \
48  }
49 
50 #ifdef USE_AMI601
51 #include "peripherals/ami601.h"
52 #define foo_handler() {}
53 #define ImuMagEvent(_mag_handler) { \
54  AMI601Event(foo_handler); \
55  if (ami601_status == AMI601_DATA_AVAILABLE) { \
56  imu.mag_unscaled.x = ami601_values[IMU_MAG_X_CHAN]; \
57  imu.mag_unscaled.y = ami601_values[IMU_MAG_Y_CHAN]; \
58  imu.mag_unscaled.z = ami601_values[IMU_MAG_Z_CHAN]; \
59  ami601_status = AMI601_IDLE; \
60  _mag_handler(); \
61  } \
62  }
63 #elif defined USE_HMC5843
64 #include "peripherals/hmc5843.h"
65 #define foo_handler() {}
66 #define ImuMagEvent(_mag_handler) { \
67  MagEvent(foo_handler); \
68  if (hmc5843.data_available) { \
69  imu.mag_unscaled.x = hmc5843.data.value[IMU_MAG_X_CHAN]; \
70  imu.mag_unscaled.y = hmc5843.data.value[IMU_MAG_Y_CHAN]; \
71  imu.mag_unscaled.z = hmc5843.data.value[IMU_MAG_Z_CHAN]; \
72  _mag_handler(); \
73  hmc5843.data_available = FALSE; \
74  } \
75  }
76 #else
77 #define ImuMagEvent(_mag_handler) {}
78 #endif
79 
80 /* underlying architecture */
81 #include "subsystems/imu/imu_crista_arch.h"
82 /* must be defined by underlying architecture */
83 extern void imu_crista_arch_init(void);
84 
85 
86 
87 #endif /* IMU_CRISTA_H */
unsigned short uint16_t
Definition: types.h:16
Inertial Measurement Unit interface.
#define ADS8344_NB_CHANNELS
Definition: imu_crista.h:30
uint16_t ADS8344_values[ADS8344_NB_CHANNELS]
Definition: ADS8344.c:41
volatile bool_t ADS8344_available
Definition: ADS8344.c:40
void imu_crista_arch_init(void)