-
Notifications
You must be signed in to change notification settings - Fork 178
Add porting guide for Hardware CRC HAL module #505
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
Changes from 6 commits
62d097b
6a737ab
fbe7ea2
6f51a82
b0edd7a
f82d0fc
b6bb35d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
## Hardware CRC | ||
|
||
The hardware CRC HAL API provides a low-level interface to the hardware CRC module of a target platform. Implementing the hardware CRC API allows you to gain the performance benefits of using hardware acceleration for CRC calculations. For platforms without hardware CRC capabilities, the API falls back to using the table and bitwise CRC implementations. | ||
|
||
<span class="notes">**Note:** The hardware CRC APIs are not thread safe.</span> | ||
|
||
#### Assumptions | ||
|
||
##### Defined behavior | ||
|
||
- Calling `hal_crc_compute_partial_start()` multiple times overrides the current CRC configuration and calculation. | ||
- The current intermediate calculation is lost if the module is reconfigured with `hal_crc_compute_partial_start()`. | ||
- `hal_crc_compute_partial()` does nothing if either the buffer is undefined or the size is equal to 0. | ||
- `hal_crc_compute_partial()` is safe to call multiple times. The new data is appended to the current calculation. | ||
- `hal_crc_is_supported` must return false if the the platform cannot support the initial or final values or data reflection in or out that the input polynomial requires. | ||
|
||
##### Undefined behavior | ||
|
||
- Calling the `hal_crc_get_result()` function multiple times is undefined. The contents of the result register after it has been read is platform-specific. The HAL API makes no assumptions about what the register contains, so it is not safe to call this multiple times. | ||
- Calling the `hal_crc_partial_start()` function with a polynomial unsupported by the current platform is undefined. Polynomial support should be checked before this function is called. | ||
- Calling the `hal_crc_get_result()` function before calling `hal_crc_partial_start()` is undefined. The module must be initialized before the get result function can return meaningful values. | ||
- Calling the `hal_crc_compute_partial()` function before calling `hal_crc_partial_start()` is undefined. The hardware CRC module must be configured correctly using the start function before writing data to it. | ||
|
||
#### Dependency | ||
|
||
The hardware CRC module in the MCU that supports at least one of the following defined polynomials: `POLY_8BIT_CCITT, POLY_7BIT_SD, POLY_16BIT_CCITT, POLY_16BIT_IBM, POLY_32BIT_ANSI ` | ||
|
||
#### Implementing the CRC API | ||
|
||
You can find the API and specification for the hardware CRC API in the following header file: | ||
|
||
[](http://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/group__hal__crc.html) | ||
|
||
To enable hardware CRC support in Mbed OS, add the `CRC` label in the `device_has` option of the target's section in the `targets.json` file. | ||
|
||
#### Testing | ||
|
||
The Mbed OS HAL API provides a set of conformance tests for Hardware CRC. You can use these tests to validate the correctness of your implementation. To run the hardware CRC HAL tests, use the following command: | ||
|
||
``` | ||
mbed test -t <toolchain> -m <target> -n "tests-mbed_hal-crc*" | ||
``` | ||
|
||
You can read more about the test cases here: | ||
|
||
``` | ||
Fix link after code is merged. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Query: Where do we find the tests? I think they should be on this page? https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/modules.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests still haven't been merged. The PR is here: ARMmbed/mbed-os#6831 |
||
``` |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note here is required for Hardware CRC - not thread safe, else can add it to undefined behavior section