Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Max32630_One_Wire_Interface
Diff: RomId.cpp
- Revision:
- 74:23be10c32fa3
- Parent:
- 73:2cecc1372acc
- Child:
- 75:8b627804927c
diff -r 2cecc1372acc -r 23be10c32fa3 RomId.cpp
--- a/RomId.cpp Thu May 12 14:38:16 2016 -0500
+++ b/RomId.cpp Fri May 13 07:48:35 2016 -0500
@@ -36,24 +36,30 @@
uint8_t RomId::calculateCRC8(uint8_t crc8, uint8_t data)
{
- int i;
+ int i;
- // See Application Note 27
- crc8 = crc8 ^ data;
- for (i = 0; i < 8; ++i)
- {
- if (crc8 & 1)
- crc8 = (crc8 >> 1) ^ 0x8c;
- else
- crc8 = (crc8 >> 1);
- }
+ // See Application Note 27
+ crc8 = crc8 ^ data;
+ for (i = 0; i < 8; i++)
+ {
+ if (crc8 & 1)
+ {
+ crc8 = (crc8 >> 1) ^ 0x8c;
+ }
+ else
+ {
+ crc8 = (crc8 >> 1);
+ }
+ }
- return crc8;
+ return crc8;
}
uint8_t RomId::calculateCRC8(const uint8_t * data, size_t data_len, uint8_t crc)
{
- for (size_t i = 0; i < data_len; i++)
- crc = calculateCRC8(crc, data[i]);
- return crc;
+ for (size_t i = 0; i < data_len; i++)
+ {
+ crc = calculateCRC8(crc, data[i]);
+ }
+ return crc;
}