Skip to content

Commit 2ce3a4a

Browse files
Angelo Scialabbacmaglie
authored andcommitted
Bridge: CRC16 being used as CRC
1 parent ce8c212 commit 2ce3a4a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

hardware/arduino/avr/libraries/Bridge/Bridge.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include "Bridge.h"
20+
#include <util/crc16.h>
2021

2122
BridgeClass::BridgeClass(Stream &_stream) :
2223
index(0), stream(_stream), started(false), max_retries(0) {
@@ -94,12 +95,14 @@ unsigned int BridgeClass::get(const char *key, uint8_t *value, unsigned int maxl
9495
}
9596

9697
void BridgeClass::crcUpdate(uint8_t c) {
97-
CRC = CRC ^ c;
98-
CRC = (CRC >> 8) + (CRC << 8);
98+
99+
CRC = _crc_ccitt_update(CRC, c);
100+
//CRC = CRC ^ c;
101+
//CRC = (CRC >> 8) + (CRC << 8);
99102
}
100103

101104
void BridgeClass::crcReset() {
102-
CRC = 0xAAAA;
105+
CRC = 0xFFFF;
103106
}
104107

105108
void BridgeClass::crcWrite() {

0 commit comments

Comments
 (0)