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_b2.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
3  * Copyright (C) 2012 Gautier Hattenberger
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 
32 #include "subsystems/imu.h"
33 
35 
36 PRINT_CONFIG_VAR(IMU_B2_MAG_TYPE)
37 
38 void imu_impl_init(void) {
39 
40  max1168_init();
41 #if defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_MS2100
42  ms2100_init(&ms2100, &(MS2100_SPI_DEV), MS2100_SLAVE_IDX);
43 #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_AMI601
44  ami601_init();
45 #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_HMC5843
46  hmc5843_init();
47 #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_HMC58XX
48  hmc58xx_init(&imu_b2.mag_hmc, &(IMU_B2_I2C_DEV), HMC58XX_ADDR);
49 #endif
50 
51 }
52 
53 #include "led.h"
54 void imu_periodic(void) {
55 
56  // read adc
58  // read mag
59 #if defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_MS2100
61 #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_AMI601
62  RunOnceEvery(10, { ami601_read(); });
63 #elif defined IMU_B2_MAG_TYPE && IMU_B2_MAG_TYPE == IMU_B2_MAG_HMC58XX
64  RunOnceEvery(5, hmc58xx_periodic(&imu_b2.mag_hmc));
65 #endif
66 
67 }
68 
void ami601_init(void)
Definition: ami601.c:12
void max1168_init(void)
Definition: max1168.c:40
#define HMC58XX_ADDR
Definition: hmc58xx_regs.h:31
struct ImuBooz2 imu_b2
Definition: imu_b2.c:34
void imu_periodic(void)
Definition: imu_b2.c:54
void hmc5843_init(void)
Definition: hmc5843.c:16
struct Ms2100 ms2100
Definition: ms2100.c:44
#define Max1168Periodic()
Definition: max1168.h:68
Inertial Measurement Unit interface.
void imu_impl_init(void)
Definition: imu_b2.c:38
void ami601_read(void)
Definition: ami601.c:25
static void hmc58xx_periodic(struct Hmc58xx *hmc)
convenience function: read or start configuration if not already initialized
Definition: hmc58xx.h:84
void ms2100_init(struct Ms2100 *ms, struct spi_periph *spi_p, uint8_t slave_idx)
Definition: ms2100.c:47
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:62
static void ms2100_periodic(struct Ms2100 *ms)
Definition: ms2100.h:65