Merge pull request #12 from tico-tico/master

Use avr-libc implementation of crc8
This commit is contained in:
Paul Stoffregen
2016-03-02 20:19:50 -08:00
2 changed files with 9 additions and 1 deletions
+4
View File
@@ -521,6 +521,9 @@ uint8_t OneWire::crc8(const uint8_t *addr, uint8_t len)
uint8_t crc = 0;
while (len--) {
#if defined(__AVR__)
crc = _crc_ibutton_update(crc, *addr++);
#else
uint8_t inbyte = *addr++;
for (uint8_t i = 8; i; i--) {
uint8_t mix = (crc ^ inbyte) & 0x01;
@@ -528,6 +531,7 @@ uint8_t OneWire::crc8(const uint8_t *addr, uint8_t len)
if (mix) crc ^= 0x8C;
inbyte >>= 1;
}
#endif
}
return crc;
}
+4
View File
@@ -3,6 +3,10 @@
#include <inttypes.h>
#if defined(__AVR__)
#include <util/crc16.h>
#endif
#if ARDUINO >= 100
#include "Arduino.h" // for delayMicroseconds, digitalPinToBitMask, etc
#else