From f7f47fe6b26d95d811279cf0b416be29912aa33b 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 cdc8b4497c..2d3c289de5 100644 --- a/src/drivers/mpu6000/mpu6000.cpp +++ b/src/drivers/mpu6000/mpu6000.cpp @@ -1696,8 +1696,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)