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

[Core] Add CRC8 calculation subsystem to quantum #12641

Merged
merged 1 commit into from
Jun 17, 2021

Conversation

KarlK90
Copy link
Member

@KarlK90 KarlK90 commented Apr 21, 2021

  • Intended usage is data validation in extensible split data sync code.
  • Default is space efficient algorithm with opt-in fast table based algorithm by #define CRC8_USE_TABLE switch.
  • Define switches for size and speed optimized versions, the default is size optimized by using uint_least8_t as datatype for calculations.
    • #define CRC8_OPTIMIZE_SPEED uses uint_fast8_t as datatype for calculations, this only affects 32-bit Archs like ARM and RISC-V.
    • Placeholder crc_init() function for hardware backed crc calculation, not implemented yet.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

  • none

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • [?] My change requires a change to the documentation.
  • [?] I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@github-actions github-actions bot added the core label Apr 21, 2021
Copy link
Member

@tzarc tzarc left a comment

Choose a reason for hiding this comment

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

It's just what I always wanted.

Thanks for helping get this stuff over the line!

@tzarc
Copy link
Member

tzarc commented Apr 21, 2021

For clarity, I'd been in discussion with @KarlK90 who had implemented the CRC8 using on-chip hardware -- I suggested that perhaps we formalise the CRC "subsystem" so that we can start adding things like the ChibiOS hardware drivers down the line.

@KarlK90
Copy link
Member Author

KarlK90 commented Apr 21, 2021

For reference this is what a hardware implementation could look like. From personal testing the fast table based crc8 implementation is faster.

Copy link
Member

@drashna drashna left a comment

Choose a reason for hiding this comment

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

__attribute__((weak))

@drashna
Copy link
Member

drashna commented May 9, 2021

Also, has merge conflict

@KarlK90
Copy link
Member Author

KarlK90 commented May 9, 2021

Fixed!

For reference CRC8 table algorithm was generated by https://pycrc.org/.

* Intended usage is data validation in split transport code.
* Default space efficient algorithm.
* Opt-in fast table based algorithmn with #define CRC8_USE_TABLE switch.
* Define switches for size and speed optimized versions, the default is size
  optimized by using uint_least8_t as datatype for calculations.
  * #define CRC8_OPTIMIZE_SPEED uses uint_fast8_t as datatype for
    calculations, this only affects 32-bit Archs like ARM and RISC-V.
* Placeholder crc_init() function for hardware backed crc calculation,
  not implemented yet.
@zvecr zvecr merged commit ef92c9e into qmk:develop Jun 17, 2021
nhongooi pushed a commit to nhongooi/qmk_firmware that referenced this pull request Dec 5, 2021
* Intended usage is data validation in split transport code.
* Default space efficient algorithm.
* Opt-in fast table based algorithmn with #define CRC8_USE_TABLE switch.
* Define switches for size and speed optimized versions, the default is size
  optimized by using uint_least8_t as datatype for calculations.
  * #define CRC8_OPTIMIZE_SPEED uses uint_fast8_t as datatype for
    calculations, this only affects 32-bit Archs like ARM and RISC-V.
* Placeholder crc_init() function for hardware backed crc calculation,
  not implemented yet.
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
* Intended usage is data validation in split transport code.
* Default space efficient algorithm.
* Opt-in fast table based algorithmn with #define CRC8_USE_TABLE switch.
* Define switches for size and speed optimized versions, the default is size
  optimized by using uint_least8_t as datatype for calculations.
  * #define CRC8_OPTIMIZE_SPEED uses uint_fast8_t as datatype for
    calculations, this only affects 32-bit Archs like ARM and RISC-V.
* Placeholder crc_init() function for hardware backed crc calculation,
  not implemented yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants