The Hardware CRC HAL API provides a low-level interface to the Hardware CRC module of a target platform. More...
|crc hal tests|
|The crc HAL tests ensure driver conformance to defined behaviour. |
|void||hal_crc_compute_partial_start (const crc_mbed_config_t *config)|
|Initialize the hardware CRC module with the given polynomial. More...|
|void||hal_crc_compute_partial (const uint8_t *data, const size_t size)|
|Writes data to the current CRC module. More...|
The Hardware CRC HAL API provides a low-level interface to the Hardware CRC module of a target platform.
Platform support for particular CRC polynomials is indicated by the macro HAL_CRC_IS_SUPPORTED(polynomial, width), which must be defined in device.h, or a file included from there.
The macro must evaluate to a constant boolean expression when given constant parameters.
The current platform must support the given polynomial with all possible other config parameters if the macro evaluates to true. These are: reflect in, reflect out, initial xor and final xor. If any of these settings of these settings cannot be configured, the polynomial is not supported.
#define HAL_CRC_IS_SUPPORTED(polynomial, width) \ ((width) == 16 || ((width) == 32 && (polynomial) == POLY_32BIT_ANSI)
|void hal_crc_compute_partial||(||const uint8_t *||data,|
Writes data to the current CRC module.
Writes input data buffer bytes to the CRC data register. The CRC module must interpret the data as an array of bytes.
The final transformations are not applied to the data; the CRC module must retain the intermediate result so that additional calls to this function can be made, appending the additional data to the calculation.
To obtain the final result of the CRC calculation, hal_crc_get_result() is called to apply the final transformations to the data.
If the function is passed an undefined pointer, or the size of the buffer is specified to be 0, this function does nothing and returns.
This function can be called multiple times in succession. This can be used to calculate the CRC result of streamed data.
This function is not thread safe. There is only one instance of the CRC module active at a time. Calling this function from multiple contexts appends different data to the same, single instance of the module, which causes an erroneous value to be calculated.
|data||Input data stream to be written into the CRC calculation|
|size||Size of the data stream in bytes|
|void hal_crc_compute_partial_start||(||const crc_mbed_config_t *||config||)|
Initialize the hardware CRC module with the given polynomial.
After calling this function, the CRC HAL module is ready to receive data using the hal_crc_compute_partial() function. The CRC module on the board is configured internally with the specified configuration and is ready to receive data.
The platform configures itself based on the default configuration parameters of the input polynomial.
This function must be called before calling hal_crc_compute_partial().
This function must be called with a valid polynomial supported by the platform. The polynomial must be checked for support using the HAL_CRC_IS_SUPPORTED() macro.
Calling hal_crc_compute_partial_start() multiple times without finalizing the CRC calculation with hal_crc_get_result() overrides the current configuration and state, and the intermediate result of the computation is lost.
This function is not thread safe. A CRC calculation must not be started from two different threads or contexts at the same time; calling this function from two different contexts may lead to configurations being overwritten and results being lost.
|config||Contains CRC configuration parameters for initializing the hardware CRC module. For example, polynomial and initial seed values.|