Cyclic Redundancy Check#
Introduction#
The Cyclic Redundancy Check (CRC) is a method used to verify the integrity of data in embedded systems. CRCs are commonly employed in communication protocols, storage devices, and error detection algorithms. By generating a checksum, CRC helps ensure that the data received or stored is accurate and unaltered.
Common use cases for CRC include:
Error Detection: Identifying data transmission errors in communication protocols.
Data Integrity Verification: Ensuring stored data remains uncorrupted.
Checksum Calculation: Generating checksums for data validation.
Configuration#
CRC can be configured using several parameters, including:
Polynomial: The polynomial used for CRC calculation (sl_crc_params_t).
Width: The width of the CRC polynomial.
Data Input Type: The width of the data input for the CRC engine.
These configurations are encapsulated in the sl_crc_params_t structure and initialized using the respective CRC APIs.
For more details on configuration parameters, see the respective peripheral example readme document.
Usage#
After defining the CRC configuration structures and passing an instance of sl_crc_params_t, the following functions can be used to initiate and configure the CRC module. The typical flow for implementation is as follows:
Set general control: sl_si91x_crc_set_gen_control
Enable CRC peripheral: sl_si91x_crc_enable
Load polynomial value: sl_si91x_crc_polynomial
Set polynomial width: sl_si91x_crc_polynomial_width
Initialize LFSR: sl_si91x_crc_lfsr_init
Configure data width type: sl_si91x_crc_set_data_width_type
Monitor CRC calculation: sl_si91x_crc_monitor_crc_calc
Reset FIFO: sl_si91x_crc_reset_fifo
Disable CRC peripheral: sl_si91x_crc_disable /
Typedefs#
Renamed CRC param structure.
Functions#
Clears the FIFO and resets all state machines.
To retrieve the general status of the CRC signals.
To load the polynomial value into the polynomial register.
To set the width of the polynomial for CRC computation.
To initialize the LFSR value for CRC computation.
To load a swapped version of the LFSR init value into the LFSR state.
To set and control the data width types for CRC computation.
To set the FIFO threshold levels for CRC computation.
To set the input data for CRC calculation.
To monitor the CRC calculation status and return the CRC value.
To write the LFSR state directly for dynamic operation.
To reset the FIFO pointer and clear the FIFO.
To retrieve the FIFO status of the CRC occupancy.
To enable the CRC peripheral by enabling its clock.
To disable the CRC peripheral by disabling its clock.
Macros#
Polynomial used for CRC calculation.
Width of the polynomial.
Initial LFSR value.
Type of CRC.
Width of the input data.
Number of bytes to be written to the CRC.
Empty threshold level.
Full threshold level.
Swap the input data.
Use uDMA for CRC calculation.
Swap the LFSR value.
Typedef Documentation#
sl_crc_params_t#
typedef RSI_CRC_PARAMS_T sl_crc_params_t
Renamed CRC param structure.
50
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
Function Documentation#
sl_si91x_crc_set_gen_control#
sl_status_t sl_si91x_crc_set_gen_control (void )
Clears the FIFO and resets all state machines.
N/A |
This API clears the FIFO and resets all state machines. It ensures that the CRC module is in a known state before starting a new operation.
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - Invalid parameter.
For more information on status codes, see SL STATUS DOCUMENTATION.
76
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_get_general_status#
sl_status_t sl_si91x_crc_get_general_status (uint32_t * reg_status)
To retrieve the general status of the CRC signals.
[out] | reg_status | Pointer to store the status of the GEN_STS Register. |
This API retrieves the general status of the CRC signals and stores it in the provided pointer.
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_NULL_POINTER (0x0021) - Invalid null pointer received as an argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
92
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_polynomial#
sl_status_t sl_si91x_crc_polynomial (sl_crc_params_t * pCRCParams)
To load the polynomial value into the polynomial register.
[in] | pCRCParams | Pointer to the CRC parameters structure containing the polynomial value. |
This API loads the polynomial value into the polynomial register using the provided CRC parameters.
Pre-conditions:
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success
SL_STATUS_NULL_POINTER (0x0021) - Invalid null pointer received as an argument.
For more information on status codes, see SL STATUS DOCUMENTATION.
110
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_polynomial_width#
sl_status_t sl_si91x_crc_polynomial_width (sl_crc_params_t * pCRCParams, uint32_t * reg_status)
To set the width of the polynomial for CRC computation.
[in] | pCRCParams | Pointer to the CRC parameters structure containing the polynomial width. |
[out] | reg_status | Pointer to store the FIFO status register value. |
This API sets the width of the polynomial for CRC computation. If a new width needs to be configured, clear the existing length first by writing 0x1F to the polynomial_ctrl_reset register.
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - Invalid parameters.
For more information on status codes, see SL STATUS DOCUMENTATION.
128
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_lfsr_init#
sl_status_t sl_si91x_crc_lfsr_init (sl_crc_params_t * pCRCParams)
To initialize the LFSR value for CRC computation.
[in] | pCRCParams | Pointer to the CRC parameters structure containing the LFSR value. |
This API initializes the Linear Feedback Shift Register (LFSR) value for CRC computation. The LFSR needs to be initialized with the init value whenever required.
Pre-conditions:
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Invalid parameters
For more information on status codes, see SL STATUS DOCUMENTATION.
147
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_use_swapped_init#
sl_status_t sl_si91x_crc_use_swapped_init (sl_crc_params_t * pCRCParams, uint32_t * reg_status)
To load a swapped version of the LFSR init value into the LFSR state.
[in] | pCRCParams | Pointer to the CRC parameters structure. |
[out] | reg_status | Pointer to store the FIFO status register value. |
This API loads a swapped version of the Linear Feedback Shift Register (LFSR) init value into the LFSR state. It is used to initialize the LFSR with a swapped init value for CRC computation.
Pre-conditions:
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
168
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
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)
To set and control the data width types for CRC computation.
[in] | pCRCParams | Pointer to the CRC parameters structure containing the data width type. |
[out] | oper_status | Pointer to store the operation status of the API process. |
This API sets and controls the data width types for CRC computation using the provided CRC parameters.
Returns
Status code:
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
185
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_set_fifo_thresholds#
sl_status_t sl_si91x_crc_set_fifo_thresholds (sl_crc_params_t * pCRCParams, uint32_t * oper_status)
To set the FIFO threshold levels for CRC computation.
[in] | pCRCParams | Pointer to the CRC parameters structure containing the FIFO thresholds (aempty and afull). |
[out] | oper_status | Pointer to store the operation status of the API process. |
This API sets the FIFO threshold levels for CRC computation. The maximum value for both thresholds is 15.
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
202
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
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)
To set the input data for CRC calculation.
[in] | pCRCParams | Pointer to the CRC parameters structure. |
[in] | data | Input data for CRC calculation. |
[out] | oper_status | Pointer to store the status of the operation. |
This API sets the input data for CRC calculation using the provided CRC parameters.
Pre-conditions:
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
227
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_monitor_crc_calc#
sl_status_t sl_si91x_crc_monitor_crc_calc (sl_crc_params_t * pCRCParams, uint32_t * crc)
To monitor the CRC calculation status and return the CRC value.
[in] | pCRCParams | Pointer to the CRC parameters structure. |
[out] | crc | Pointer to store the calculated CRC value. |
This API monitors the CRC calculation status and returns the calculated CRC value.
Pre-conditions:
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
251
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_lfsr_dynamic_write#
sl_status_t sl_si91x_crc_lfsr_dynamic_write (sl_crc_params_t * pCRCParams)
To write the LFSR state directly for dynamic operation.
[in] | pCRCParams | Pointer to the CRC parameters structure containing the LFSR state. |
This API writes the Linear Feedback Shift Register (LFSR) state directly for dynamic operation.
Pre-conditions:
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
270
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_reset_fifo#
sl_status_t sl_si91x_crc_reset_fifo (void )
To reset the FIFO pointer and clear the FIFO.
N/A |
This API resets the FIFO pointer and clears the FIFO, ensuring that the FIFO is empty and ready for new data.
Pre-conditions:
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success
SL_STATUS_FAIL (0x0001) - Function failed
For more information on status codes, see SL STATUS DOCUMENTATION.
285
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_get_fifo_status#
sl_status_t sl_si91x_crc_get_fifo_status (uint32_t * reg_status)
To retrieve the FIFO status of the CRC occupancy.
[out] | reg_status | Pointer to store the FIFO status register value. |
This API retrieves the FIFO status of the CRC occupancy and stores the status in the provided register.
Pre-conditions:
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid.
For more information on status codes, see SL STATUS DOCUMENTATION.
304
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_enable#
sl_status_t sl_si91x_crc_enable (void )
To enable the CRC peripheral by enabling its clock.
N/A |
This API enables the CRC peripheral by enabling its clock, allowing CRC operations to be performed.
Returns
Status code indicating the result::
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_FAIL (0x0001) - Function failed.
For more information on status codes, see SL STATUS DOCUMENTATION.
318
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
sl_si91x_crc_disable#
sl_status_t sl_si91x_crc_disable (void )
To disable the CRC peripheral by disabling its clock.
N/A |
This API disables the CRC peripheral by disabling its clock, preventing any further CRC operations.
Pre-conditions:
Returns
Status code indicating the result:
SL_STATUS_OK (0x0000) - Success.
SL_STATUS_FAIL (0x0001) - Function failed.
For more information on status codes, see SL STATUS DOCUMENTATION.
335
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
Macro Definition Documentation#
SL_CRC_POLYNOMIAL#
#define SL_CRC_POLYNOMIALValue:
0x04C11DB7
Polynomial used for CRC calculation.
51
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
SL_CRC_POLY_WIDTH#
#define SL_CRC_POLY_WIDTHValue:
31
Width of the polynomial.
52
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
SL_CRC_LFSR_VAL#
#define SL_CRC_LFSR_VALValue:
0x0000
Initial LFSR value.
53
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
SL_CRC_WIDTH_TYPE#
#define SL_CRC_WIDTH_TYPEValue:
0
Type of CRC.
54
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
SL_CRC_DIN_WIDTH#
#define SL_CRC_DIN_WIDTHValue:
31
Width of the input data.
55
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
SL_CRC_NUM_BYTES#
#define SL_CRC_NUM_BYTESValue:
3
Number of bytes to be written to the CRC.
56
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
SL_CRC_AEMPTY#
#define SL_CRC_AEMPTYValue:
6
Empty threshold level.
57
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
SL_CRC_AFULL#
#define SL_CRC_AFULLValue:
2
Full threshold level.
58
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
SL_CRC_SWAP_DIN#
#define SL_CRC_SWAP_DINValue:
0
Swap the input data.
59
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
SL_CRC_USE_UDMA#
#define SL_CRC_USE_UDMAValue:
1
Use uDMA for CRC calculation.
60
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h
SL_CRC_SWAP_LFSR#
#define SL_CRC_SWAP_LFSRValue:
1
Swap the LFSR value.
61
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h