Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lookup table based crc-8 implementation #492

Merged
merged 1 commit into from
Mar 4, 2020
Merged

lookup table based crc-8 implementation #492

merged 1 commit into from
Mar 4, 2020

Conversation

buha
Copy link
Contributor

@buha buha commented Feb 21, 2020

This is code compatible with linux crc8.h although the implementation is
somewhat different.

This implementation is supposed to replace all crc-8 implementations in no-OS
drivers which are all duplicates of each other.

By comparing the performance of this new implementation with the old one on
an x86 machine and on large sample sizes, it seems the new implementation is
faster by a factor of 13.

I suggest to review but not merge this until we have a working projects/ad7768-1 to test it on. I did test it on x86 and gives the same result as our existing algorithm.

@buha buha requested a review from a team February 21, 2020 11:20
* @return crc - Computed CRC-8 value.
*******************************************************************************/
uint8_t crc8(const uint8_t * table, const uint8_t *pdata, size_t nbytes,
uint8_t crc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the description says the last parameter (crc) represents the initial value, wouldn't it be more clear to rename it this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i added more explanation to the function documentation. basically, the value you put there is typically a crc so i think it makes sense the stay that way

util/crc8.c Outdated
* @brief Source file of CRC-8 computation.
* @author Darius Berghe ([email protected])
********************************************************************************
* Copyright 2012(c) Analog Devices, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2012 -> 2020.

util/crc8.c Outdated

return crc;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: extra line :D

This is code compatible with linux crc8.h although the implementation is
somewhat different.

This implementation is supposed to replace all crc-8 implementations in no-OS
drivers which are all duplicates of each other.

By comparing the performance of this new implementation with the old one on
an x86 machine and on large sample sizes, it seems the new implementation is
faster by a factor of 13.

Signed-off-by: Darius Berghe <[email protected]>
@buha
Copy link
Contributor Author

buha commented Mar 1, 2020

Following previous comments I:

  • fixed file header with year
  • removed extra lines
  • ellaborated a bit more the doxy description of crc8()

@dbogdan dbogdan merged commit dd669d0 into master Mar 4, 2020
@dbogdan dbogdan deleted the crc8 branch March 4, 2020 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants