1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-26 17:55:30 +03:00

Fix gyro reading in gyroUpdate function

This commit is contained in:
Martin Budden 2017-01-07 21:37:58 +00:00
parent 65074bafe1
commit 72b15e1c97

View file

@ -401,15 +401,14 @@ static bool gyroUpdateISR(gyroDev_t* gyroDev)
void gyroUpdate(void) void gyroUpdate(void)
{ {
// range: +/- 8192; +/- 2000 deg/sec // range: +/- 8192; +/- 2000 deg/sec
#if defined(MPU_INT_EXTI) if (gyro.dev.update) {
if (!gyro.dev.dataReady || !gyro.dev.read(&gyro.dev)) { // if the gyro update function is set then return, since the gyro is read in gyroUpdateISR
return; return;
} }
#else
if (!gyro.dev.read(&gyro.dev)) { if (!gyro.dev.read(&gyro.dev)) {
return; return;
} }
#endif gyro.dev.dataReady = false;
const bool calibrationComplete = isGyroCalibrationComplete(); const bool calibrationComplete = isGyroCalibrationComplete();
if (calibrationComplete) { if (calibrationComplete) {
@ -424,7 +423,6 @@ void gyroUpdate(void)
debug[3] = (uint16_t)(micros() & 0xffff); debug[3] = (uint16_t)(micros() & 0xffff);
#endif #endif
} }
gyro.dev.dataReady = false;
// move gyro data into 32-bit variables to avoid overflows in calculations // move gyro data into 32-bit variables to avoid overflows in calculations
gyroADC[X] = gyro.dev.gyroADCRaw[X]; gyroADC[X] = gyro.dev.gyroADCRaw[X];
gyroADC[Y] = gyro.dev.gyroADCRaw[Y]; gyroADC[Y] = gyro.dev.gyroADCRaw[Y];