Loop once per 5 seconds.
Clean up CRC8 functions (style, no caps).
This commit is contained in:
@ -38,13 +38,13 @@ static bool mgos_sht31_cmd(struct mgos_sht31 *sensor, uint16_t cmd) {
|
||||
|
||||
static uint8_t crc8(const uint8_t *data, int len)
|
||||
{
|
||||
const uint8_t POLYNOMIAL=0x31;
|
||||
const uint8_t poly=0x31;
|
||||
uint8_t crc=0xFF;
|
||||
|
||||
for (int j=len; j; --j ) {
|
||||
crc ^= *data++;
|
||||
for ( int i = 8; i; --i )
|
||||
crc = ( crc & 0x80 ) ? (crc << 1) ^ POLYNOMIAL : (crc << 1);
|
||||
for (int j=len; j; --j) {
|
||||
crc^=*data++;
|
||||
for (int i=8; i; --i)
|
||||
crc=(crc & 0x80) ? (crc << 1) ^ poly : (crc << 1);
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
Reference in New Issue
Block a user