[imu] Remove ppzuav

This commit is contained in:
Freek van Tienen
2022-05-18 13:31:11 +02:00
parent 6afa3e0945
commit 0a4e9d4d51
3 changed files with 0 additions and 287 deletions
-46
View File
@@ -1,46 +0,0 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="imu_pprzuav" dir="imu" task="sensors">
<doc>
<description>
PPZUAV IMU.
- Accelerometer: ADXL345 via I2C
- Gyroscope: ITG3200 via I2C
- Magnetometer: HMC58xx via I2C
</description>
<configure name="IMU_PPZUAV_I2C_DEV" value="i2c2" description="I2C device to use"/>
<section name="IMU" prefix="IMU_">
<define name="MAG_X_NEUTRAL" value="2358"/>
<define name="MAG_Y_NEUTRAL" value="2362"/>
<define name="MAG_Z_NEUTRAL" value="2119"/>
<define name="MAG_X_SENS" value="3.4936416" integer="16"/>
<define name="MAG_Y_SENS" value="3.607713" integer="16"/>
<define name="MAG_Z_SENS" value="4.90788848" integer="16"/>
</section>
</doc>
<dep>
<depends>i2c,imu_common</depends>
<provides>imu,mag</provides>
</dep>
<autoload name="imu_nps"/>
<autoload name="imu_sim"/>
<header>
<file name="imu_ppzuav.h"/>
</header>
<init fun="imu_ppzuav_init()"/>
<periodic fun="imu_ppzuav_periodic()"/>
<event fun="imu_ppzuav_event()"/>
<makefile target="!sim|nps|fbw">
<configure name="IMU_PPZUAV_I2C_DEV" default="i2c2" case="lower|upper"/>
<define name="IMU_PPZUAV_I2C_DEV" value="$(IMU_PPZUAV_I2C_DEV_LOWER)"/>
<define name="USE_$(IMU_PPZUAV_I2C_DEV_UPPER)"/>
<define name="IMU_TYPE_H" value="imu/imu_ppzuav.h" type="string"/>
<file name="adxl345_i2c.c" dir="peripherals"/>
<file name="itg3200.c" dir="peripherals"/>
<file name="hmc58xx.c" dir="peripherals"/>
<file name="imu_ppzuav.c"/>
</makefile>
</module>
-147
View File
@@ -1,147 +0,0 @@
/*
* Copyright (C) 2010 Antoine Drouin <poinix@gmail.com>
* 2013 Felix Ruess <felix.ruess@gmail.com>
*
* 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);
}
}
-94
View File
@@ -1,94 +0,0 @@
/*
* Copyright (C) 2010 Antoine Drouin <poinix@gmail.com>
* 2013 Felix Ruess <felix.ruess@gmail.com>
*
* 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 */