This repository has been archived by the owner on Aug 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use CRC16 to verify heater PID settings in eeprom
- Loading branch information
Showing
4 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "crc.h" | ||
|
||
#include <util/crc16.h> | ||
|
||
// uint16_t _crc16_update(uint16_t crc, uint8_t a) { | ||
// int i; | ||
// crc ^= a; | ||
// for (i = 0; i < 8; ++i) | ||
// { | ||
// if (crc & 1) | ||
// crc = (crc >> 1) ^ 0xA001; | ||
// else | ||
// crc = (crc >> 1); | ||
// } | ||
// return crc; | ||
// } | ||
|
||
uint16_t crc_block(void *data, uint16_t len) { | ||
uint16_t crc = 0; | ||
for (; len; data++, len--) { | ||
crc = _crc16_update(crc, *((uint8_t *) data)); | ||
} | ||
return crc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef _CRC_H | ||
#define _CRC_H | ||
|
||
#include <stdint.h> | ||
|
||
uint16_t crc_block(void *data, uint16_t len); | ||
|
||
#endif /* _CRC_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters