mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 17:25:20 +03:00
MS5611 - Remove profanity. Replace comment with code. Improve code
size. Improve code readability.
This commit is contained in:
parent
98f5bdd986
commit
043577b8af
1 changed files with 5 additions and 9 deletions
|
@ -106,19 +106,15 @@ static int8_t ms5611_crc(uint16_t *prom)
|
||||||
{
|
{
|
||||||
int32_t i, j;
|
int32_t i, j;
|
||||||
uint32_t res = 0;
|
uint32_t res = 0;
|
||||||
uint8_t zero = 1;
|
|
||||||
uint8_t crc = prom[7] & 0xF;
|
uint8_t crc = prom[7] & 0xF;
|
||||||
prom[7] &= 0xFF00;
|
prom[7] &= 0xFF00;
|
||||||
|
|
||||||
// if eeprom is all zeros, we're probably fucked - BUT this will return valid CRC lol
|
bool blankEeprom = true;
|
||||||
for (i = 0; i < 8; i++) {
|
|
||||||
if (prom[i] != 0)
|
|
||||||
zero = 0;
|
|
||||||
}
|
|
||||||
if (zero)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
|
if (prom[i >> 1]) {
|
||||||
|
blankEeprom = false;
|
||||||
|
}
|
||||||
if (i & 1)
|
if (i & 1)
|
||||||
res ^= ((prom[i >> 1]) & 0x00FF);
|
res ^= ((prom[i >> 1]) & 0x00FF);
|
||||||
else
|
else
|
||||||
|
@ -130,7 +126,7 @@ static int8_t ms5611_crc(uint16_t *prom)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prom[7] |= crc;
|
prom[7] |= crc;
|
||||||
if (crc == ((res >> 12) & 0xF))
|
if (!blankEeprom && crc == ((res >> 12) & 0xF))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue