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_crista.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
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 
22 #ifndef IMU_CRISTA_H
23 #define IMU_CRISTA_H
24 
25 #include "subsystems/imu.h"
26 #include "generated/airframe.h"
27 
28 #define ADS8344_NB_CHANNELS 8
30 extern volatile bool_t ADS8344_available;
31 
32 #define ImuEvent(_gyro_handler, _accel_handler, _mag_handler) { \
33  if (ADS8344_available) { \
34  ADS8344_available = FALSE; \
35  imu.gyro_unscaled.p = ADS8344_values[IMU_GYRO_P_CHAN]; \
36  imu.gyro_unscaled.q = ADS8344_values[IMU_GYRO_Q_CHAN]; \
37  imu.gyro_unscaled.r = ADS8344_values[IMU_GYRO_R_CHAN]; \
38  imu.accel_unscaled.x = ADS8344_values[IMU_ACCEL_X_CHAN]; \
39  imu.accel_unscaled.y = ADS8344_values[IMU_ACCEL_Y_CHAN]; \
40  imu.accel_unscaled.z = ADS8344_values[IMU_ACCEL_Z_CHAN]; \
41  /* spare 3, temp 7 */ \
42  _gyro_handler(); \
43  _accel_handler(); \
44  } \
45  ImuMagEvent(_mag_handler); \
46  }
47 
48 #ifdef USE_AMI601
49 #include "peripherals/ami601.h"
50 #define foo_handler() {}
51 #define ImuMagEvent(_mag_handler) { \
52  AMI601Event(foo_handler); \
53  if (ami601_status == AMI601_DATA_AVAILABLE) { \
54  imu.mag_unscaled.x = ami601_values[IMU_MAG_X_CHAN]; \
55  imu.mag_unscaled.y = ami601_values[IMU_MAG_Y_CHAN]; \
56  imu.mag_unscaled.z = ami601_values[IMU_MAG_Z_CHAN]; \
57  ami601_status = AMI601_IDLE; \
58  _mag_handler(); \
59  } \
60  }
61 #elif defined USE_HMC5843
62 #include "peripherals/hmc5843.h"
63 #define foo_handler() {}
64 #define ImuMagEvent(_mag_handler) { \
65  MagEvent(foo_handler); \
66  if (hmc5843.data_available) { \
67  imu.mag_unscaled.x = hmc5843.data.value[IMU_MAG_X_CHAN]; \
68  imu.mag_unscaled.y = hmc5843.data.value[IMU_MAG_Y_CHAN]; \
69  imu.mag_unscaled.z = hmc5843.data.value[IMU_MAG_Z_CHAN]; \
70  _mag_handler(); \
71  hmc5843.data_available = FALSE; \
72  } \
73  }
74 #else
75 #define ImuMagEvent(_mag_handler) {}
76 #endif
77 
78 /* underlying architecture */
79 #include "subsystems/imu/imu_crista_arch.h"
80 /* must be defined by underlying architecture */
81 extern void imu_crista_arch_init(void);
82 
83 
84 
85 #endif /* IMU_CRISTA_H */
unsigned short uint16_t
Definition: types.h:16
Inertial Measurement Unit interface.
#define ADS8344_NB_CHANNELS
Definition: imu_crista.h:28
uint16_t ADS8344_values[ADS8344_NB_CHANNELS]
Definition: ADS8344.c:39
volatile bool_t ADS8344_available
Definition: ADS8344.c:38
void imu_crista_arch_init(void)