HAL CRC How to Use ¶
- group CRC_How_To_Use
-
How to use the CRC HAL module driver ¶
The CRC HAL driver can be used as follows: ¶
-
Declare a hal_crc_handle_t handle structure, for example: hal_crc_handle_t hcrc;
-
Initialize the CRC handle by calling the HAL_CRC_Init() API that performs these operations:
-
The Association of the instance to the handle
-
The initialization of the handle state to the HAL_CRC_STATE_IDLE
-
-
Enable the CRC peripheral clock:
-
Either at application level by calling the HAL_RCC_CRC_EnableClock() API
-
Or by setting the USE_HAL_CRC_CLK_ENABLE_MODEL define to HAL_CLK_ENABLE_PERIPH_ONLY within the stm32u5xx_hal_conf.h file, in this case the CRC clock will be enabled within the HAL_CRC_Init() API
-
-
Keep the default configuration (default registers values) or configure the CRC module with user values:
-
Declare a hal_crc_config_t structure
-
Fill all parameters of the declared configuration structure
-
Call HAL_CRC_SetConfig()
function, this function:
Updates the CRC registers according to the user configuration provided by the input config structure
-
-
When there is a need to restore the CRC default configuration use the HAL_CRC_ResetConfig()
API:
This function allows to reset the CRC configuration to the default one by setting the following fields to their default values:
-
The polynomial coefficient is set to 0x04C11DB7U
-
The polynomial size is set to 32-bits
-
The CRC init value is set to 0xFFFFFFFFU
-
The input reversibility mode is set to none
-
The output reversibility mode is set to none
-
-
For CRC IO operations, one operation mode is available within this driver: Polling mode IO operation
-
Computing the CRC value of the input data buffer starting with the configured CRC initialization value Using HAL_CRC_Calculate() function
-
Computing the CRC value of the input data buffer starting with the previously computed CRC Using HAL_CRC_Accumulate() function
-
-
Deinitialize the CRC peripheral by calling the HAL_CRC_DeInit() API that performs these operations:
-
The reset of the CRC configuration to the default one by setting the following fields to their default values:
-
The polynomial coefficient is set to 0x04C11DB7U
-
The polynomial size is set to 32-bits
-
The CRC init value is set to 0xFFFFFFFFU
-
The input reversibility mode is set to none
-
The output reversibility mode is set to none
-
-
The reset of the independent data value to the default one(0xFFFFFFFFU)
-
The reset of the handle state to the HAL_CRC_STATE_RESET
-
-