Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_hbmini.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2011 Paparazzi Team
3  * Derived from Aspirin, NavGo 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 
33 #include <math.h>
34 #include "imu_hbmini.h"
35 #include "mcu_periph/i2c.h"
36 #include "led.h"
37 
38 // Downlink
39 #include "mcu_periph/uart.h"
40 #include "messages.h"
42 
43 
44 #if !defined IMU_GYRO_P_CHAN & !defined IMU_GYRO_Q_CHAN & !defined IMU_GYRO_R_CHAN
45 #define IMU_GYRO_P_CHAN 3
46 #define IMU_GYRO_Q_CHAN 4
47 #define IMU_GYRO_R_CHAN 5
48 #endif
49 #if !defined IMU_ACCEL_X_CHAN & !defined IMU_ACCEL_Y_CHAN & !defined IMU_ACCEL_Z_CHAN
50 #define IMU_ACCEL_X_CHAN 0
51 #define IMU_ACCEL_Y_CHAN 1
52 #define IMU_ACCEL_Z_CHAN 2
53 #endif
54 #if !defined IMU_MAG_X_CHAN & !defined IMU_MAG_Y_CHAN & !defined IMU_MAG_Z_CHAN
55 #define IMU_MAG_X_CHAN 2
56 #define IMU_MAG_Y_CHAN 0
57 #define IMU_MAG_Z_CHAN 1
58 #endif
59 
61 
62 void imu_impl_init(void)
63 {
64 
65  max1168_init();
66 
68  // HMC58XX
69  hmc58xx_init(&imu_hbmini.hmc, &(IMU_HBMINI_I2C_DEV), HMC58XX_ADDR);
70 
74 
75 }
76 
77 void imu_periodic( void )
78 {
79 
81 
82  // Read HMC58XX at 100Hz (main loop for rotorcraft: 512Hz)
83  RunOnceEvery(5, hmc58xx_periodic(&imu_hbmini.hmc));
84 
85  //RunOnceEvery(20,imu_hbmini_downlink_raw());
86 }
87 
88 
90 {
94 }
95 
96 void imu_hbmini_event( void )
97 {
98 
99  max1168_event();
100 
101 
112  }
113 
114  // HMC58XX event task
120 
123  }
124 
125 }
126 
void max1168_init(void)
Definition: max1168.c:40
void max1168_event(void)
Definition: max1168.c:98
#define IMU_MAG_Y_CHAN
Definition: imu_hbmini.c:56
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
uint16_t max1168_values[MAX1168_NB_CHAN]
Definition: max1168.c:28
int32_t p
in rad/s with INT32_RATE_FRAC
#define IMU_GYRO_P_CHAN
Definition: imu_hbmini.c:45
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:49
void imu_hbmini_event(void)
Definition: imu_hbmini.c:96
union Hmc58xx::@29 data
volatile bool_t acc_valid
Definition: imu_hbmini.h:65
#define MAX1168_IDLE
Definition: max1168.h:59
#define HMC58XX_ADDR
Definition: hmc58xx_regs.h:31
#define FALSE
Definition: imu_chimu.h:141
int16_t value[3]
data values accessible by channel index
Definition: hmc58xx.h:68
volatile bool_t gyr_valid
Definition: imu_hbmini.h:64
volatile bool_t mag_valid
Definition: imu_hbmini.h:66
#define IMU_ACCEL_Y_CHAN
Definition: imu_hbmini.c:51
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:50
struct ImuHbmini imu_hbmini
Definition: imu_hbmini.c:60
void imu_hbmini_downlink_raw(void)
Definition: imu_hbmini.c:89
#define IMU_GYRO_Q_CHAN
Definition: imu_hbmini.c:46
struct Imu imu
global IMU state
Definition: imu_aspirin2.c:47
#define IMU_GYRO_R_CHAN
Definition: imu_hbmini.c:47
#define Max1168Periodic()
Definition: max1168.h:68
#define IMU_MAG_Z_CHAN
Definition: imu_hbmini.c:57
#define IMU_ACCEL_Z_CHAN
Definition: imu_hbmini.c:52
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
Definition: imu.h:51
#define TRUE
Definition: imu_chimu.h:144
volatile uint8_t max1168_status
Definition: max1168.c:27
#define MAX1168_DATA_AVAILABLE
Definition: max1168.h:63
static void hmc58xx_periodic(struct Hmc58xx *hmc)
convenience function: read or start configuration if not already initialized
Definition: hmc58xx.h:84
void imu_impl_init(void)
Definition: imu_hbmini.c:62
#define IMU_MAG_X_CHAN
Definition: imu_hbmini.c:55
int32_t q
in rad/s with INT32_RATE_FRAC
arch independent LED (Light Emitting Diodes) API
void hmc58xx_init(struct Hmc58xx *hmc, struct i2c_periph *i2c_p, uint8_t addr)
Initialize Hmc58xx struct and set default config options.
Definition: hmc58xx.c:75
struct Hmc58xx hmc
Definition: imu_hbmini.h:69
int32_t r
in rad/s with INT32_RATE_FRAC
void imu_periodic(void)
Definition: imu_hbmini.c:77
void hmc58xx_event(struct Hmc58xx *hmc)
Definition: hmc58xx.c:151
volatile bool_t data_available
data ready flag
Definition: hmc58xx.h:65
#define IMU_ACCEL_X_CHAN
Definition: imu_hbmini.c:50
Architecture independent I2C (Inter-Integrated Circuit Bus) API.