Cyclic Redundancy Check#
Introduction#
The Cyclic Redundancy Check (CRC) in embedded systems identifies inadvertent data changes. It generates a checksum, which is applied to the data before transmission or storage. When data is received or retrieved, the CRC is recalculated and compared to the original checksum to confirm its integrity.
Configuration#
Configuring CRC typically involves several parameters like below:
Modify
SL_CRC_POLYNOMIAL
to set the desired polynomial value.Modify
SL_CRC_POLY_WIDTH
to set the desired polynomial width.
Usage#
The common CRC functions can be used after the CRC Structures are specified, passing an instance of sl_crc_params_t. The following functions will initiate and configure the CRC below, which is the flow for implementation.
sl_si91x_crc_set_gen_control
sl_si91x_crc_polynomial
sl_si91x_crc_polynomial_width
sl_si91x_crc_lfsr_init
sl_si91x_crc_use_swapped_init
sl_si91x_crc_set_data_width_type
sl_si91x_crc_set_fifo_thresholds
sl_si91x_crc_monitor_crc_calc
Typedefs#
Renamed CRC param structure.
Functions#
Enables the CRC peripheral.
Disable the CRC peripheral.
Macros#
Polynomial used for CRC calculation.
Width of the polynomial.
Initial LFSR value.
Width type of the CRC.
Width of the input data.
Number of bytes to be written to the CRC.
Almost empty threshold level.
Almost full threshold level.
Whether to swap the input data.
Whether to use uDMA for CRC calculation.
Whether to swap the LFSR value.
Typedef Documentation#
Function Documentation#
sl_si91x_crc_set_gen_control#
sl_status_t sl_si91x_crc_set_gen_control (void )
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
sl_si91x_crc_get_general_status#
sl_status_t sl_si91x_crc_get_general_status (uint32_t * reg_status)
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t * | N/A | reg_status |
sl_si91x_crc_polynomial#
sl_status_t sl_si91x_crc_polynomial (sl_crc_params_t * pCRCParams)
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_crc_params_t * | N/A | pCRCParams |
sl_si91x_crc_polynomial_width#
sl_status_t sl_si91x_crc_polynomial_width (sl_crc_params_t * pCRCParams, uint32_t * reg_status)
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_crc_params_t * | N/A | pCRCParams | |
uint32_t * | N/A | reg_status |
sl_si91x_crc_lfsr_init#
sl_status_t sl_si91x_crc_lfsr_init (sl_crc_params_t * pCRCParams)
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_crc_params_t * | N/A | pCRCParams |
sl_si91x_crc_use_swapped_init#
sl_status_t sl_si91x_crc_use_swapped_init (sl_crc_params_t * pCRCParams, uint32_t * reg_status)
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_crc_params_t * | N/A | pCRCParams | |
uint32_t * | N/A | reg_status |
sl_si91x_crc_set_data_width_type#
sl_status_t sl_si91x_crc_set_data_width_type (sl_crc_params_t * pCRCParams, uint32_t * oper_status)
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_crc_params_t * | N/A | pCRCParams | |
uint32_t * | N/A | oper_status |
sl_si91x_crc_set_fifo_thresholds#
sl_status_t sl_si91x_crc_set_fifo_thresholds (sl_crc_params_t * pCRCParams, uint32_t * oper_status)
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_crc_params_t * | N/A | pCRCParams | |
uint32_t * | N/A | oper_status |
sl_si91x_crc_write_data#
sl_status_t sl_si91x_crc_write_data (sl_crc_params_t * pCRCParams, uint32_t data, uint32_t * oper_status)
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_crc_params_t * | N/A | pCRCParams | |
uint32_t | N/A | data | |
uint32_t * | N/A | oper_status |
sl_si91x_crc_monitor_crc_calc#
sl_status_t sl_si91x_crc_monitor_crc_calc (sl_crc_params_t * pCRCParams, uint32_t * crc)
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_crc_params_t * | N/A | pCRCParams | |
uint32_t * | N/A | crc |
sl_si91x_crc_lfsr_dynamic_write#
sl_status_t sl_si91x_crc_lfsr_dynamic_write (sl_crc_params_t * pCRCParams)
Type | Direction | Argument Name | Description |
---|---|---|---|
sl_crc_params_t * | N/A | pCRCParams |
sl_si91x_crc_reset_fifo#
sl_status_t sl_si91x_crc_reset_fifo (void )
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
sl_si91x_crc_get_fifo_status#
sl_status_t sl_si91x_crc_get_fifo_status (uint32_t * reg_status)
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t * | N/A | reg_status |
sl_si91x_crc_enable#
sl_status_t sl_si91x_crc_enable (void )
Enables the CRC peripheral.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function enables the CRC peripheral by enabling its clock.
Returns
status 0 if successful, else error code as follow
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
sl_si91x_crc_disable#
sl_status_t sl_si91x_crc_disable (void )
Disable the CRC peripheral.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This function Disables the CRC peripheral by disabling its clock.
Returns
status 0 if successful, else error code as follow
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.