mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 07:43:34 +08:00
MS5611: Increase the requirements about the PROM contents and CRC.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user