MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / crc8

Method crc8

libraries/SHT31/SHT31.cpp:289–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287//////////////////////////////////////////////////////////
288
289uint8_t SHT31::crc8(const uint8_t *data, uint8_t len)
290{
291 // CRC-8 formula from page 14 of SHT spec pdf
292 const uint8_t POLY(0x31);
293 uint8_t crc(0xFF);
294
295 for (uint8_t j = len; j; --j)
296 {
297 crc ^= *data++;
298
299 for (uint8_t i = 8; i; --i)
300 {
301 crc = (crc & 0x80) ? (crc << 1) ^ POLY : (crc << 1);
302 }
303 }
304 return crc;
305}
306
307
308bool SHT31::writeCmd(uint16_t cmd)

Callers 4

beginMethod · 0.45
beginMethod · 0.45
beginMethod · 0.45
getTempCMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected