The MCUXpresso SDK provides a peripheral driver for the Cyclic Redundancy Check (CRC) module of MCUXpresso SDK devices.
The cyclic redundancy check (CRC) module generates 16/32-bit CRC code for error detection. The CRC module also provides a programmable polynomial, seed, and other parameters required to implement a 16-bit or 32-bit CRC standard.
|
| void | CRC_Init (CRC_Type *base) |
| | Enables the CRC peripheral module. More...
|
| |
| void | CRC_Deinit (CRC_Type *base) |
| | Disables the CRC peripheral module. More...
|
| |
| void | CRC_GetDefaultConfig (crc_config_t *config) |
| | Provide default CRC protocol configuration. More...
|
| |
| void | CRC_SetConfig (CRC_Type *base, const crc_config_t *config) |
| | Configures the CRC peripheral module. More...
|
| |
| static void | CRC_SetSeed (CRC_Type *base, uint32_t crcPreload) |
| | Set the CRC seed value. More...
|
| |
| void | CRC_WriteData (CRC_Type *base, const uint8_t *buffer, uint32_t len) |
| | Set CRC type of transpose of write data. More...
|
| |
| static uint32_t | CRC_GetResult (CRC_Type *base) |
| | Reads the checksum from the CRC module. More...
|
| |
|
static void | CRC_Init (void) |
| | Enables the CRC peripheral module.
|
| |
|
static void | CRC_DeInit (void) |
| | Disables the CRC peripheral module.
|
| |
| static status_t | CRC_CalculateCrc (uint32_t crcPreload, uint8_t *buffer, uint32_t dataLength, uint32_t *crcValue) |
| | This function calculate CRC32 or CRC16 on selected data area. More...
|
| |
| static status_t | CRC_CheckCrc16 (uint16_t crcPreload, uint8_t *buffer, uint32_t dataLength) |
| | This function check CRC16 calculation on buffer with calculated CRC value. More...
|
| |
| static status_t | CRC_CalculateHDLLCrc16 (uint16_t crcPreload, uint8_t *buffer, uint32_t dataLength, uint16_t *crcValue) |
| | This function calculate CRC16 on selected FW buffer area. More...
|
| |
| static status_t | CRC_CheckHDLLCrc16 (uint16_t crcPreload, uint8_t *buffer, uint32_t dataLength) |
| | This function check CRC16 calculation on incoming frame buffer with calculated CRC value. More...
|
| |
| static status_t | CRC_Calc (uint8_t *buffer, uint32_t length) |
| | This function calculates the CRC on selected FW buffer area using the CRC HW. More...
|
| |
This structure holds the configuration for the CRC protocol.
| bool crc_config_t::crcEnable |
| #define FSL_CRC_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
| #define FSL_CRC_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
CRC-16: poly:0x1021 CRC-32: poly:0x04C11DB7
| Enumerator |
|---|
| kCRC_Crc16 |
CRC-16 protocol.
|
| kCRC_Crc32 |
CRC-32 protocol.
|
| Enumerator |
|---|
| kCRC_MsbFirst |
MSB, in this mode, refIn = false, refOut = false.
|
| kCRC_LsbFirst |
LSB, in this mode, refIn = true, refOut = true.
|
| Enumerator |
|---|
| kStatus_CRC_ParameterError |
Value to be returned in case of wrong parameter.
|
| kStatus_CRC_InternalError |
Value to be returned in case of an internal error or an error which is not specified in more detail.
|
| kStatus_CRC_Busy |
Device or resource busy.
|
| void CRC_Init |
( |
CRC_Type * |
base | ) |
|
This function enables the clock gate for the CRC peripheral.
- Parameters
-
| base | CRC peripheral address. |
| void CRC_Deinit |
( |
CRC_Type * |
base | ) |
|
This function disables the clock gate for the CRC peripheral.
- Parameters
-
| base | CRC peripheral address. |
The purpose of this API is to initialize the configuration structure to default value for CRC_SetConfig to use. Provides the configuration of commonly used CRC protocols. The default configuration is:
This is an example:
- Parameters
-
| config | CRC protocol configuration structure. |
| void CRC_SetConfig |
( |
CRC_Type * |
base, |
|
|
const crc_config_t * |
config |
|
) |
| |
This function configures the CRC module and starts a checksum computation by writing the seed.
- Parameters
-
| base | CRC peripheral address. |
| config | CRC module configuration structure. |
| static void CRC_SetSeed |
( |
CRC_Type * |
base, |
|
|
uint32_t |
crcPreload |
|
) |
| |
|
inlinestatic |
This function is help to write a 16/32 bit CRC seed value.
- Parameters
-
| base | CRC peripheral address. |
| crcPreload | The value of seed. |
| void CRC_WriteData |
( |
CRC_Type * |
base, |
|
|
const uint8_t * |
buffer, |
|
|
uint32_t |
len |
|
) |
| |
This function writes data to CRC.
- Parameters
-
| base | CRC peripheral address. |
| buffer | data message to be checked. |
| len | length of buffer. |
| static uint32_t CRC_GetResult |
( |
CRC_Type * |
base | ) |
|
|
inlinestatic |
Reads the CRC data register (either an intermediate or the final checksum).
- Parameters
-
| base | CRC peripheral address. |
- Returns
- An intermediate or the final checksum, after transpose and complement operations configured.
| static status_t CRC_CalculateCrc |
( |
uint32_t |
crcPreload, |
|
|
uint8_t * |
buffer, |
|
|
uint32_t |
dataLength, |
|
|
uint32_t * |
crcValue |
|
) |
| |
|
inlinestatic |
This function is protected by semaphore. Functions that are protected by semaphores must not be called in interrupts. CRC will always calculate MSB first, this will be set internally
- Parameters
-
| crcPreload | : Value of pre-load DATA for CRC calculation |
| buffer | :Pointer to data message structure on which CRC will be calculated. |
| dataLength | : Length of buffer in bytes Note - Len must match with Buffer size. |
| crcValue | : Pointer on calculated CRC value |
- Return values
-
| kStatus_Success | Operation Successful. |
| kStatus_CRC_ParameterError | Unknown EEPROM address or address pointed by pDataToWrite is incorrect. |
| kStatus_CRC_Busy | |
| kStatus_CRC_InternalError | |
| static status_t CRC_CheckCrc16 |
( |
uint16_t |
crcPreload, |
|
|
uint8_t * |
buffer, |
|
|
uint32_t |
dataLength |
|
) |
| |
|
inlinestatic |
- Note
- It is assumed that CRC16 result is part of the buffer (usually last two bytes, after data on which CRC is calculated )
-
Function is protected by semaphore
-
Functions that are protected by semaphores must not be called in interrupts
-
CRC will always calculate MSB first, this will be set internally
- Parameters
-
| crcPreload | : Value of pre-load DATA for CRC calculation |
| buffer | :Pointer to data message structure on which CRC will be calculated. |
| dataLength | : Length of buffer in bytes Note - Len must match with Buffer size. |
- Return values
-
| kStatus_Success | Operation Successful. |
| kStatus_CRC_ParameterError | Unknown EEPROM address or address pointed by pDataToWrite is incorrect. |
| kStatus_CRC_Busy | |
| kStatus_CRC_InternalError | |
| static status_t CRC_CalculateHDLLCrc16 |
( |
uint16_t |
crcPreload, |
|
|
uint8_t * |
buffer, |
|
|
uint32_t |
dataLength, |
|
|
uint16_t * |
crcValue |
|
) |
| |
|
inlinestatic |
- Note
- Function is protected by semaphore
-
Functions that are protected by semaphores must not be called in interrupts
-
CRC will always calculate lsb first and byte by byte, but buffer doesn't have to be aligned
- Parameters
-
| crcPreload | : Value of pre-load DATA for CRC calculation |
| buffer | :Pointer to data message structure on which CRC will be calculated. |
| dataLength | : Length of buffer in bytes Note - Len must match with Buffer size. |
| crcValue | : Pointer on calculated CRC value |
- Return values
-
| kStatus_Success | Operation Successful. |
| kStatus_CRC_ParameterError | Unknown EEPROM address or address pointed by pDataToWrite is incorrect. |
| kStatus_CRC_Busy | |
| kStatus_CRC_InternalError | |
| static status_t CRC_CheckHDLLCrc16 |
( |
uint16_t |
crcPreload, |
|
|
uint8_t * |
buffer, |
|
|
uint32_t |
dataLength |
|
) |
| |
|
inlinestatic |
- Note
- It is assumed that CRC16 result is part of the buffer (usually last two bytes, after data on which CRC is calculated )
-
Function is protected by semaphore
-
Functions that are protected by semaphores must not be called in interrupts
-
CRC will always calculate lsb first and byte by byte, but buffer doesn't have to be aligned
- Parameters
-
| crcPreload | : Value of pre-load DATA for CRC calculation |
| buffer | :Pointer to data message structure on which CRC will be calculated. |
| dataLength | : Length of buffer in bytes Note - Len must match with Buffer size. |
- Return values
-
| kStatus_Success | Operation Successful. |
| kStatus_CRC_ParameterError | Unknown EEPROM address or address pointed by pDataToWrite is incorrect. |
| kStatus_CRC_Busy | |
| kStatus_CRC_InternalError | |
| static status_t CRC_Calc |
( |
uint8_t * |
buffer, |
|
|
uint32_t |
length |
|
) |
| |
|
inlinestatic |
- Note
- CRC will always calculate lsb first and byte by byte, but buffer doesn't have to be aligned
- Parameters
-
| buffer | :Pointer to data message structure on which CRC will be calculated. |
| length | : Length of buffer in bytes Note - Len must match with Buffer size. |
- Return values
-
| kStatus_Success | Operation Successful. |
| kStatus_CRC_ParameterError | Unknown EEPROM address or address pointed by pDataToWrite is incorrect. |
| kStatus_CRC_Busy | |
| kStatus_CRC_InternalError | |