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.

  1. sl_si91x_crc_set_gen_control

  2. sl_si91x_crc_enable

  3. sl_si91x_crc_polynomial

  4. sl_si91x_crc_polynomial_width

  5. sl_si91x_crc_lfsr_init

  6. sl_si91x_crc_use_swapped_init

  7. sl_si91x_crc_set_data_width_type

  8. sl_si91x_crc_set_fifo_thresholds

  9. sl_si91x_crc_monitor_crc_calc

  10. sl_si91x_crc_disable

Typedefs#

typedef RSI_CRC_PARAMS_T

Renamed CRC param structure.

Functions#

sl_status_t
sl_si91x_crc_get_general_status(uint32_t *reg_status)
sl_status_t
sl_si91x_crc_polynomial(sl_crc_params_t *pCRCParams)
sl_status_t
sl_si91x_crc_polynomial_width(sl_crc_params_t *pCRCParams, uint32_t *reg_status)
sl_status_t
sl_si91x_crc_lfsr_init(sl_crc_params_t *pCRCParams)
sl_status_t
sl_si91x_crc_use_swapped_init(sl_crc_params_t *pCRCParams, uint32_t *reg_status)
sl_status_t
sl_si91x_crc_set_data_width_type(sl_crc_params_t *pCRCParams, uint32_t *oper_status)
sl_status_t
sl_si91x_crc_set_fifo_thresholds(sl_crc_params_t *pCRCParams, uint32_t *oper_status)
sl_status_t
sl_si91x_crc_write_data(sl_crc_params_t *pCRCParams, uint32_t data, uint32_t *oper_status)
sl_status_t
sl_si91x_crc_monitor_crc_calc(sl_crc_params_t *pCRCParams, uint32_t *crc)
sl_status_t
sl_si91x_crc_lfsr_dynamic_write(sl_crc_params_t *pCRCParams)
sl_status_t
sl_status_t
sl_si91x_crc_get_fifo_status(uint32_t *reg_status)
sl_status_t

Enables the CRC peripheral.

sl_status_t

Disable the CRC peripheral.

Macros#

#define

Polynomial used for CRC calculation.

#define

Width of the polynomial.

#define

Initial LFSR value.

#define

Width type of the CRC.

#define

Width of the input data.

#define

Number of bytes to be written to the CRC.

#define

Almost empty threshold level.

#define

Almost full threshold level.

#define

Whether to swap the input data.

#define

Whether to use uDMA for CRC calculation.

#define

Whether to swap the LFSR value.

Typedef Documentation#

sl_crc_params_t#

typedef RSI_CRC_PARAMS_T sl_crc_params_t

Renamed CRC param structure.


Definition at line 49 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 )
Parameters
N/A

Definition at line 114 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)
Parameters
N/Areg_status

Definition at line 126 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)
Parameters
N/ApCRCParams

Definition at line 139 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)
Parameters
N/ApCRCParams
N/Areg_status

Definition at line 155 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)
Parameters
N/ApCRCParams

Definition at line 167 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)
Parameters
N/ApCRCParams
N/Areg_status

Definition at line 180 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)
Parameters
N/ApCRCParams
N/Aoper_status

Definition at line 195 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)
Parameters
N/ApCRCParams
N/Aoper_status

Definition at line 208 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)
Parameters
N/ApCRCParams
N/Adata
N/Aoper_status

Definition at line 224 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)
Parameters
N/ApCRCParams
N/Acrc

Definition at line 237 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)
Parameters
N/ApCRCParams

Definition at line 248 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 )
Parameters
N/A

Definition at line 258 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)
Parameters
N/Areg_status

Definition at line 268 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 )

Enables the CRC peripheral.

Parameters
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.


Definition at line 279 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 )

Disable the CRC peripheral.

Parameters
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.


Definition at line 292 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h

Macro Definition Documentation#

SL_CRC_POLYNOMIAL#

#define SL_CRC_POLYNOMIAL
Value:
0x04C11DB7

Polynomial used for CRC calculation.


Definition at line 54 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h

SL_CRC_POLY_WIDTH#

#define SL_CRC_POLY_WIDTH
Value:
31

Width of the polynomial.


Definition at line 59 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h

SL_CRC_LFSR_VAL#

#define SL_CRC_LFSR_VAL
Value:
0x0000

Initial LFSR value.


Definition at line 64 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h

SL_CRC_WIDTH_TYPE#

#define SL_CRC_WIDTH_TYPE
Value:
0

Width type of the CRC.


Definition at line 69 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h

SL_CRC_DIN_WIDTH#

#define SL_CRC_DIN_WIDTH
Value:
31

Width of the input data.


Definition at line 74 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h

SL_CRC_NUM_BYTES#

#define SL_CRC_NUM_BYTES
Value:
3

Number of bytes to be written to the CRC.


Definition at line 79 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h

SL_CRC_AEMPTY#

#define SL_CRC_AEMPTY
Value:
6

Almost empty threshold level.


Definition at line 84 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h

SL_CRC_AFULL#

#define SL_CRC_AFULL
Value:
2

Almost full threshold level.


Definition at line 89 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h

SL_CRC_SWAP_DIN#

#define SL_CRC_SWAP_DIN
Value:
0

Whether to swap the input data.


Definition at line 94 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h

SL_CRC_USE_UDMA#

#define SL_CRC_USE_UDMA
Value:
1

Whether to use uDMA for CRC calculation.


Definition at line 99 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h

SL_CRC_SWAP_LFSR#

#define SL_CRC_SWAP_LFSR
Value:
1

Whether to swap the LFSR value.


Definition at line 104 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_crc.h