isentek/ist8308: set sensor_mag error count and fix bitwise AND

This commit is contained in:
Daniel Agar 2020-09-02 13:19:27 -04:00 committed by Beat Küng
parent 19b43b5e9c
commit bf41574b1d

View File

@ -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;