From fcc85f79d5e22d3e7793e864d39a1d39b62758b1 Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Sun, 18 Dec 2016 12:12:42 +0100 Subject: [PATCH] MPU6K: Make stop routine safe to call from any location in the startup code --- src/drivers/mpu6000/mpu6000.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/drivers/mpu6000/mpu6000.cpp b/src/drivers/mpu6000/mpu6000.cpp index 86e72c5682..74de1e8efc 100644 --- a/src/drivers/mpu6000/mpu6000.cpp +++ b/src/drivers/mpu6000/mpu6000.cpp @@ -1709,8 +1709,13 @@ MPU6000::stop() memset(_last_accel, 0, sizeof(_last_accel)); /* discard unread data in the buffers */ - _accel_reports->flush(); - _gyro_reports->flush(); + if (_accel_reports != nullptr) { + _accel_reports->flush(); + } + + if (_gyro_reports != nullptr) { + _gyro_reports->flush(); + } } #if defined(USE_I2C)