Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_crista.c
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 #include "subsystems/imu.h"
23 #include "subsystems/abi.h"
24 
25 volatile bool ADS8344_available;
27 
28 void imu_crista_init(void)
29 {
30 
31  ADS8344_available = false;
32 
34 
35 #ifdef USE_AMI601
36  ami601_init();
37 #endif
38 #ifdef USE_HMC5843
39  hmc5843_init();
40 #endif
41 
42 }
43 
45 {
46 
48 #ifdef USE_AMI601
49  RunOnceEvery(10, { ami601_read(); });
50 #endif
51 #ifdef USE_HMC5843
53 #endif
54 }
55 
56 
57 
58 #ifdef USE_AMI601
59 #include "peripherals/ami601.h"
60 #define foo_handler() {}
61 static inline void ImuMagEvent()
62 {
63  AMI601Event(foo_handler);
70  AbiSendMsgIMU_MAG_INT32(IMU_CRISTA_ID, now_ts, &imu.mag);
71  }
72 }
73 #elif defined USE_HMC5843
74 #include "peripherals/hmc5843.h"
75 static inline void ImuMagEvent(void)
76 {
78  if (hmc5843.data_available) {
82  hmc5843.data_available = false;
84  AbiSendMsgIMU_MAG_INT32(IMU_CRISTA_ID, now_ts, &imu.mag);
85  }
86 }
87 #else
88 #define ImuMagEvent() {}
89 #endif
90 
92 {
93  if (ADS8344_available) {
94  ADS8344_available = false;
101  /* spare 3, temp 7 */
104  AbiSendMsgIMU_GYRO_INT32(IMU_CRISTA_ID, now_ts, &imu.gyro);
105  AbiSendMsgIMU_ACCEL_INT32(IMU_CRISTA_ID, now_ts, &imu.accel);
106  }
107  ImuMagEvent();
108 }
void ami601_init(void)
Definition: ami601.c:12
#define IMU_MAG_Y_CHAN
Definition: imu_hbmini.c:57
unsigned short uint16_t
Definition: types.h:16
#define ImuCristaArchPeriodic()
void imu_scale_gyro(struct Imu *_imu)
Definition: ahrs_gx3.c:349
void hmc5843_idle_task(void)
Definition: hmc5843.c:60
uint8_t data_available
Definition: hmc5843.h:34
void imu_scale_accel(struct Imu *_imu)
Definition: ahrs_gx3.c:350
#define AMI601_IDLE
Definition: ami601.h:19
#define IMU_GYRO_P_CHAN
Definition: imu_hbmini.c:46
Main include for ABI (AirBorneInterface).
#define ImuMagEvent()
Definition: imu_crista.c:88
volatile uint8_t ami601_status
Definition: ami601.c:8
void imu_christa_event(void)
Definition: imu_crista.c:91
struct Imu imu
global IMU state
Definition: imu.c:108
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
Definition: imu.h:48
int32_t r
in rad/s with INT32_RATE_FRAC
void imu_crista_init(void)
Definition: imu_crista.c:28
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:46
struct Int32Vect3 accel
accelerometer measurements in m/s^2 in BFP with INT32_ACCEL_FRAC
Definition: imu.h:39
#define IMU_ACCEL_Y_CHAN
Definition: imu_hbmini.c:52
uint16_t ami601_values[AMI601_NB_CHAN]
Definition: ami601.c:6
void hmc5843_init(void)
Definition: hmc5843.c:16
#define IMU_GYRO_Q_CHAN
Definition: imu_hbmini.c:47
volatile bool ADS8344_available
Definition: imu_crista.c:25
#define IMU_CRISTA_ID
#define IMU_GYRO_R_CHAN
Definition: imu_hbmini.c:48
#define IMU_MAG_Z_CHAN
Definition: imu_hbmini.c:58
struct Int32Vect3 mag
magnetometer measurements scaled to 1 in BFP with INT32_MAG_FRAC
Definition: imu.h:40
Inertial Measurement Unit interface.
union Hmc5843::@300 data
#define IMU_ACCEL_Z_CHAN
Definition: imu_hbmini.c:53
#define ADS8344_NB_CHANNELS
Definition: imu_crista.h:28
void imu_scale_mag(struct Imu *_imu)
Definition: ahrs_gx3.c:351
void ami601_read(void)
Definition: ami601.c:26
#define AMI601Event(_handler)
Definition: ami601.h:38
void imu_crista_arch_init(void)
#define IMU_MAG_X_CHAN
Definition: imu_hbmini.c:56
uint16_t ADS8344_values[ADS8344_NB_CHANNELS]
Definition: imu_crista.c:26
#define AMI601_DATA_AVAILABLE
Definition: ami601.h:23
int32_t p
in rad/s with INT32_RATE_FRAC
void hmc5843_periodic(void)
Definition: hmc5843.c:103
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:47
#define IMU_ACCEL_X_CHAN
Definition: imu_hbmini.c:51
int32_t q
in rad/s with INT32_RATE_FRAC
struct Hmc5843 hmc5843
Definition: hmc5843.c:9
void imu_crista_periodic(void)
Definition: imu_crista.c:44
struct Int32Rates gyro
gyroscope measurements in rad/s in BFP with INT32_RATE_FRAC
Definition: imu.h:38