MS5611: Increase the requirements about the PROM contents and CRC.

This commit is contained in:
Lorenz Meier
2015-10-06 17:22:38 +02:00
parent 90f2e8d61a
commit 0490046af4
+14 -1
View File
@@ -266,6 +266,9 @@ MS5611_I2C::_read_prom()
*/
usleep(3000);
uint8_t last_val = 0;
bool bits_stuck = true;
/* read and convert PROM words */
for (int i = 0; i < 8; i++) {
uint8_t cmd = ADDR_PROM_SETUP + (i * 2);
@@ -274,6 +277,16 @@ MS5611_I2C::_read_prom()
break;
}
/* check if all bytes are zero */
if (i == 0) {
/* initalize to first byte read */
last_val = prom_buf[0];
}
if (prom_buf[0] != last_val || prom_buf[1] != last_val) {
bits_stuck = false;
}
/* assemble 16 bit value and convert from big endian (sensor) to little endian (MCU) */
cvt.b[0] = prom_buf[1];
cvt.b[1] = prom_buf[0];
@@ -281,5 +294,5 @@ MS5611_I2C::_read_prom()
}
/* calculate CRC and return success/failure accordingly */
return ms5611::crc4(&_prom.c[0]) ? PX4_OK : -EIO;
return (ms5611::crc4(&_prom.c[0]) && !bits_stuck) ? PX4_OK : -EIO;
}