mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 04:13:34 +08:00
mpu9250: decrease sampling rate when using i2c
This commit is contained in:
committed by
Beat Küng
parent
9c8e97a1ba
commit
8b54346d52
@@ -139,11 +139,7 @@ MPU9250::MPU9250(device::Device *interface, device::Device *mag_interface, const
|
||||
_gyro_range_scale(0.0f),
|
||||
_gyro_range_rad_s(0.0f),
|
||||
_dlpf_freq(MPU9250_DEFAULT_ONCHIP_FILTER_FREQ),
|
||||
#ifdef CONFIG_ARCH_BOARD_CRAZYFLIE
|
||||
_sample_rate(200),
|
||||
#else
|
||||
_sample_rate(1000),
|
||||
#endif
|
||||
_accel_reads(perf_alloc(PC_COUNT, "mpu9250_acc_read")),
|
||||
_gyro_reads(perf_alloc(PC_COUNT, "mpu9250_gyro_read")),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "mpu9250_read")),
|
||||
@@ -264,6 +260,17 @@ MPU9250::init()
|
||||
use_i2c(_interface->ioctl(MPUIOCGIS_I2C, dummy));
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If the MPU is using I2C we should reduce the sample rate to 200Hz and
|
||||
* make the integration autoreset faster so that we integrate just one
|
||||
* sample since the sampling rate is already low.
|
||||
*/
|
||||
if (is_i2c()) {
|
||||
_sample_rate = 200;
|
||||
_accel_int.set_autoreset_interval(1000000 / MPU9250_ACCEL_MAX_OUTPUT_RATE / 4);
|
||||
_gyro_int.set_autoreset_interval(1000000 / MPU9250_GYRO_MAX_OUTPUT_RATE / 4);
|
||||
}
|
||||
|
||||
int ret = probe();
|
||||
|
||||
if (ret != OK) {
|
||||
|
||||
@@ -181,11 +181,7 @@
|
||||
#define MPU_WHOAMI_6500 0x70
|
||||
|
||||
#define MPU9250_ACCEL_DEFAULT_RATE 1000
|
||||
#ifdef CONFIG_ARCH_BOARD_CRAZYFLIE
|
||||
#define MPU9250_ACCEL_MAX_OUTPUT_RATE 1000
|
||||
#else
|
||||
#define MPU9250_ACCEL_MAX_OUTPUT_RATE 280
|
||||
#endif
|
||||
#define MPU9250_ACCEL_DEFAULT_DRIVER_FILTER_FREQ 30
|
||||
#define MPU9250_GYRO_DEFAULT_RATE 1000
|
||||
/* rates need to be the same between accel and gyro */
|
||||
|
||||
Reference in New Issue
Block a user