From bf41574b1de76b347ce5d5fe04a447f01c9f12e2 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Wed, 2 Sep 2020 13:19:27 -0400 Subject: [PATCH] isentek/ist8308: set sensor_mag error count and fix bitwise AND --- src/drivers/magnetometer/isentek/ist8308/IST8308.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/drivers/magnetometer/isentek/ist8308/IST8308.cpp b/src/drivers/magnetometer/isentek/ist8308/IST8308.cpp index f00fd6e76e..1dcedf31cf 100644 --- a/src/drivers/magnetometer/isentek/ist8308/IST8308.cpp +++ b/src/drivers/magnetometer/isentek/ist8308/IST8308.cpp @@ -173,7 +173,7 @@ void IST8308::RunImpl() if (transfer(&cmd, 1, (uint8_t *)&buffer, sizeof(buffer)) == PX4_OK) { - if (buffer.STAT && STAT_BIT::DRDY) { + if (buffer.STAT & STAT_BIT::DRDY) { int16_t x = combine(buffer.DATAXH, buffer.DATAXL); int16_t y = combine(buffer.DATAYH, buffer.DATAYL); int16_t z = combine(buffer.DATAZH, buffer.DATAZL); @@ -181,6 +181,7 @@ void IST8308::RunImpl() // sensor's frame is +x forward, +y right, +z up z = (z == INT16_MIN) ? INT16_MAX : -z; // flip z + _px4_mag.set_error_count(perf_event_count(_bad_register_perf) + perf_event_count(_bad_transfer_perf)); _px4_mag.update(now, x, y, z); success = true;