From e513fd8472cccd6a46df670a8efb276226687d16 Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Fri, 6 Jan 2017 09:42:07 +0000 Subject: [PATCH] Minor fixes to gyro ISR code, as per review --- src/main/fc/config.c | 4 ++++ src/main/sensors/gyro.c | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/fc/config.c b/src/main/fc/config.c index 32bbc1906..2ad65b488 100755 --- a/src/main/fc/config.c +++ b/src/main/fc/config.c @@ -1054,6 +1054,10 @@ void validateAndFixGyroConfig(void) #endif } +#if !defined(GYRO_USES_SPI) || !defined(USE_MPU_DATA_READY_SIGNAL) + gyroConfig()->gyro_isr_update = false; +#endif + if (gyroConfig()->gyro_lpf != GYRO_LPF_256HZ && gyroConfig()->gyro_lpf != GYRO_LPF_NONE) { pidConfig()->pid_process_denom = 1; // When gyro set to 1khz always set pid speed 1:1 to sampling speed gyroConfig()->gyro_sync_denom = 1; diff --git a/src/main/sensors/gyro.c b/src/main/sensors/gyro.c index 0abf310b7..8417f0af3 100644 --- a/src/main/sensors/gyro.c +++ b/src/main/sensors/gyro.c @@ -66,7 +66,11 @@ gyro_t gyro; // gyro access functions +#if defined(GYRO_USES_SPI) && defined(USE_MPU_DATA_READY_SIGNAL) +static volatile int32_t gyroADC[XYZ_AXIS_COUNT]; +#else static int32_t gyroADC[XYZ_AXIS_COUNT]; +#endif static int32_t gyroZero[XYZ_AXIS_COUNT] = { 0, 0, 0 }; static const gyroConfig_t *gyroConfig; @@ -391,7 +395,8 @@ static bool gyroUpdateISR(gyroDev_t* gyroDev) float gyroADCf = (float)gyroADC[axis] * gyroDev->scale; gyroADCf = softLpfFilterApplyFn(softLpfFilter[axis], gyroADCf); gyroADCf = notchFilter1ApplyFn(notchFilter1[axis], gyroADCf); - gyro.gyroADCf[axis] = notchFilter2ApplyFn(notchFilter2[axis], gyroADCf); + gyroADCf = notchFilter2ApplyFn(notchFilter2[axis], gyroADCf); + gyro.gyroADCf[axis] = gyroADCf; } return true; }