MS5611 - Remove profanity. Replace comment with code. Improve code
size. Improve code readability.
This commit is contained in:
parent
98f5bdd986
commit
043577b8af
|
@ -106,19 +106,15 @@ static int8_t ms5611_crc(uint16_t *prom)
|
|||
{
|
||||
int32_t i, j;
|
||||
uint32_t res = 0;
|
||||
uint8_t zero = 1;
|
||||
uint8_t crc = prom[7] & 0xF;
|
||||
prom[7] &= 0xFF00;
|
||||
|
||||
// if eeprom is all zeros, we're probably fucked - BUT this will return valid CRC lol
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (prom[i] != 0)
|
||||
zero = 0;
|
||||
}
|
||||
if (zero)
|
||||
return -1;
|
||||
bool blankEeprom = true;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (prom[i >> 1]) {
|
||||
blankEeprom = false;
|
||||
}
|
||||
if (i & 1)
|
||||
res ^= ((prom[i >> 1]) & 0x00FF);
|
||||
else
|
||||
|
@ -130,7 +126,7 @@ static int8_t ms5611_crc(uint16_t *prom)
|
|||
}
|
||||
}
|
||||
prom[7] |= crc;
|
||||
if (crc == ((res >> 12) & 0xF))
|
||||
if (!blankEeprom && crc == ((res >> 12) & 0xF))
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue