diff --git a/conf/modules/imu_pprzuav.xml b/conf/modules/imu_pprzuav.xml deleted file mode 100644 index 0c08c82225..0000000000 --- a/conf/modules/imu_pprzuav.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - PPZUAV IMU. - - Accelerometer: ADXL345 via I2C - - Gyroscope: ITG3200 via I2C - - Magnetometer: HMC58xx via I2C - - -
- - - - - - - -
-
- - i2c,imu_common - imu,mag - - - -
- -
- - - - - - - - - - - - - - - -
diff --git a/sw/airborne/modules/imu/imu_ppzuav.c b/sw/airborne/modules/imu/imu_ppzuav.c deleted file mode 100644 index 7663e388cf..0000000000 --- a/sw/airborne/modules/imu/imu_ppzuav.c +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2010 Antoine Drouin - * 2013 Felix Ruess - * - * This file is part of paparazzi. - * - * paparazzi is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * paparazzi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with paparazzi; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/** - * @file modules/imu/imu_ppzuav.h - * - * Driver for the PPZUAV IMU. - * - * 9DoM IMU with ITG-3200, ADXL345 and HMC5843, all via I2C. - */ - -#include "modules/imu/imu.h" -#include "modules/core/abi.h" -#include "mcu_periph/i2c.h" - -/* i2c default suitable for Tiny/Twog */ -#ifndef IMU_PPZUAV_I2C_DEV -#define IMU_PPZUAV_I2C_DEV i2c0 -#endif - -/** adxl345 accelerometer output rate, lowpass is set to half of rate */ -#ifndef IMU_PPZUAV_ACCEL_RATE -# if PERIODIC_FREQUENCY <= 60 -# define IMU_PPZUAV_ACCEL_RATE ADXL345_RATE_50HZ -# elif PERIODIC_FREQUENCY <= 120 -# define IMU_PPZUAV_ACCEL_RATE ADXL345_RATE_100HZ -# else -# define IMU_PPZUAV_ACCEL_RATE ADXL345_RATE_200HZ -# endif -#endif -PRINT_CONFIG_VAR(IMU_PPZUAV_ACCEL_RATE) - - -/** gyro internal lowpass frequency */ -#ifndef IMU_PPZUAV_GYRO_LOWPASS -# if PERIODIC_FREQUENCY <= 60 -# define IMU_PPZUAV_GYRO_LOWPASS ITG3200_DLPF_20HZ -# elif PERIODIC_FREQUENCY <= 120 -# define IMU_PPZUAV_GYRO_LOWPASS ITG3200_DLPF_42HZ -# else -# define IMU_PPZUAV_GYRO_LOWPASS ITG3200_DLPF_98HZ -# endif -#endif -PRINT_CONFIG_VAR(IMU_PPZUAV_GYRO_LOWPASS) - - -/** gyro sample rate divider */ -#ifndef IMU_PPZUAV_GYRO_SMPLRT_DIV -# if PERIODIC_FREQUENCY <= 60 -# define IMU_PPZUAV_GYRO_SMPLRT_DIV 19 -PRINT_CONFIG_MSG("Gyro output rate is 50Hz") -# else -# define IMU_PPZUAV_GYRO_SMPLRT_DIV 9 -PRINT_CONFIG_MSG("Gyro output rate is 100Hz") -# endif -#endif -PRINT_CONFIG_VAR(IMU_PPZUAV_GYRO_SMPLRT_DIV) - - -struct ImuPpzuav imu_ppzuav; - -void imu_ppzuav_init(void) -{ - /* Set accel configuration */ - adxl345_i2c_init(&imu_ppzuav.acc_adxl, &(IMU_PPZUAV_I2C_DEV), ADXL345_ADDR); - /* set the data rate */ - imu_ppzuav.acc_adxl.config.rate = IMU_PPZUAV_ACCEL_RATE; - - /* Gyro configuration and initalization */ - itg3200_init(&imu_ppzuav.gyro_itg, &(IMU_PPZUAV_I2C_DEV), ITG3200_ADDR); - /* change the default config */ - imu_ppzuav.gyro_itg.config.smplrt_div = IMU_PPZUAV_GYRO_SMPLRT_DIV; - imu_ppzuav.gyro_itg.config.dlpf_cfg = IMU_PPZUAV_GYRO_LOWPASS; - - /* initialize mag and set default options */ - hmc58xx_init(&imu_ppzuav.mag_hmc, &(IMU_PPZUAV_I2C_DEV), HMC58XX_ADDR); - /* set the type to the old HMC5843 */ - imu_ppzuav.mag_hmc.type = HMC_TYPE_5843; -} - - -void imu_ppzuav_periodic(void) -{ - adxl345_i2c_periodic(&imu_ppzuav.acc_adxl); - - // Start reading the latest gyroscope data - itg3200_periodic(&imu_ppzuav.gyro_itg); - - // Read HMC58XX at 50Hz (main loop for rotorcraft: 512Hz) - RunOnceEvery(10, hmc58xx_periodic(&imu_ppzuav.mag_hmc)); -} - -void imu_ppzuav_event(void) -{ - uint32_t now_ts = get_sys_time_usec(); - - adxl345_i2c_event(&imu_ppzuav.acc_adxl); - if (imu_ppzuav.acc_adxl.data_available) { - imu.accel_unscaled.x = -imu_ppzuav.acc_adxl.data.vect.x; - imu.accel_unscaled.y = imu_ppzuav.acc_adxl.data.vect.y; - imu.accel_unscaled.z = -imu_ppzuav.acc_adxl.data.vect.z; - imu_ppzuav.acc_adxl.data_available = false; - imu_scale_accel(&imu); - AbiSendMsgIMU_ACCEL_INT32(IMU_PPZUAV_ID, now_ts, &imu.accel); - } - - /* If the itg3200 I2C transaction has succeeded: convert the data */ - itg3200_event(&imu_ppzuav.gyro_itg); - if (imu_ppzuav.gyro_itg.data_available) { - imu.gyro_unscaled.p = -imu_ppzuav.gyro_itg.data.rates.p; - imu.gyro_unscaled.q = imu_ppzuav.gyro_itg.data.rates.q; - imu.gyro_unscaled.r = -imu_ppzuav.gyro_itg.data.rates.r; - imu_ppzuav.gyro_itg.data_available = false; - imu_scale_gyro(&imu); - AbiSendMsgIMU_GYRO_INT32(IMU_PPZUAV_ID, now_ts, &imu.gyro); - } - - /* HMC58XX event task */ - hmc58xx_event(&imu_ppzuav.mag_hmc); - if (imu_ppzuav.mag_hmc.data_available) { - imu.mag_unscaled.x = -imu_ppzuav.mag_hmc.data.vect.y; - imu.mag_unscaled.y = -imu_ppzuav.mag_hmc.data.vect.x; - imu.mag_unscaled.z = -imu_ppzuav.mag_hmc.data.vect.z; - imu_ppzuav.mag_hmc.data_available = false; - imu_scale_mag(&imu); - AbiSendMsgIMU_MAG_INT32(IMU_PPZUAV_ID, now_ts, &imu.mag); - } -} diff --git a/sw/airborne/modules/imu/imu_ppzuav.h b/sw/airborne/modules/imu/imu_ppzuav.h deleted file mode 100644 index 7abeabab95..0000000000 --- a/sw/airborne/modules/imu/imu_ppzuav.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2010 Antoine Drouin - * 2013 Felix Ruess - * - * This file is part of paparazzi. - * - * paparazzi is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * paparazzi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with paparazzi; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/** - * @file modules/imu/imu_ppzuav.h - * - * Interface and defaults for the PPZUAV IMU. - * - * 9DoM IMU with ITG-3200, ADXL345 and HMC5843, all via I2C. - */ - - -#ifndef IMU_PPZUAV_H -#define IMU_PPZUAV_H - -#include "generated/airframe.h" -#include "modules/imu/imu.h" - -#include "peripherals/itg3200.h" -#include "peripherals/hmc58xx.h" -#include "peripherals/adxl345_i2c.h" - -#if !defined IMU_GYRO_P_SENS & !defined IMU_GYRO_Q_SENS & !defined IMU_GYRO_R_SENS -/** default gyro sensitivy and neutral from the datasheet - * ITG3200 has 14.375 LSB/(deg/s) - * sens = 1/14.375 * pi/180 * 2^INT32_RATE_FRAC - * sens = 1/14.375 * pi/180 * 4096 = 4.973126 - */ -#define IMU_GYRO_P_SENS 4.973 -#define IMU_GYRO_P_SENS_NUM 4973 -#define IMU_GYRO_P_SENS_DEN 1000 -#define IMU_GYRO_Q_SENS 4.973 -#define IMU_GYRO_Q_SENS_NUM 4973 -#define IMU_GYRO_Q_SENS_DEN 1000 -#define IMU_GYRO_R_SENS 4.973 -#define IMU_GYRO_R_SENS_NUM 4973 -#define IMU_GYRO_R_SENS_DEN 1000 -#endif - - -#if !defined IMU_ACCEL_X_SENS & !defined IMU_ACCEL_Y_SENS & !defined IMU_ACCEL_Z_SENS -/** default accel sensitivy from the ADXL345 datasheet - * sensitivity of x & y axes depends on supply voltage: - * - 256 LSB/g @ 2.5V - * - 265 LSB/g @ 3.3V - * z sensitivity stays at 256 LSB/g - * fixed point sens: 9.81 [m/s^2] / 256 [LSB/g] * 2^INT32_ACCEL_FRAC - * x/y sens = 9.81 / 265 * 1024 = 37.91 - * z sens = 9.81 / 256 * 1024 = 39.24 - */ -#define IMU_ACCEL_X_SENS 37.91 -#define IMU_ACCEL_X_SENS_NUM 3791 -#define IMU_ACCEL_X_SENS_DEN 100 -#define IMU_ACCEL_Y_SENS 37.91 -#define IMU_ACCEL_Y_SENS_NUM 3791 -#define IMU_ACCEL_Y_SENS_DEN 100 -#define IMU_ACCEL_Z_SENS 39.24 -#define IMU_ACCEL_Z_SENS_NUM 3924 -#define IMU_ACCEL_Z_SENS_DEN 100 -#endif - - -struct ImuPpzuav { - struct Adxl345_I2c acc_adxl; - struct Itg3200 gyro_itg; - struct Hmc58xx mag_hmc; -}; - -extern struct ImuPpzuav imu_ppzuav; - -extern void imu_ppzuav_init(void); -extern void imu_ppzuav_periodic(void); -extern void imu_ppzuav_event(void); - -#endif /* IMU_PPZUAV_H */