MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
CRC: Cyclic Redundancy Check Driver

Read Guidance

This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.

Driver Overview

 CRC Peripheral and Driver Overview
 Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method; 3) typical use case.
 
 The Driver Change Log
 The current CRC driver version is 2.0.0.
 

Data Structures

struct  crc_config_t
 CRC protocol configuration. More...
 

Enumerations

enum  crc_protocol_type_t {
  kCRC_Crc16 = 0U,
  kCRC_Crc16CCITT = 1U,
  kCRC_Crc16Kermit = 2U,
  kCRC_Crc32 = 3U,
  kCRC_Crc32Posix = 4U
}
 CRC protocol type. More...
 
enum  crc_bits_t {
  kCRC_Bits16 = 0U,
  kCRC_Bits32 = 1U
}
 CRC protocol bit width. More...
 
enum  crc_transpose_type_t {
  kCRC_TransposeNone = 0U,
  kCRC_TransposeBits = 1U,
  kCRC_TransposeBitsAndBytes = 2U,
  kCRC_TransposeBytes = 3U
}
 CRC type of transpose of read/write data. More...
 

Driver version

#define FSL_CRC_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 CRC driver version. More...
 

Initialization and De-initialization Interfaces

void CRC_Init (CRC_Type *base, const crc_config_t *psConfig)
 Enables and configures the CRC peripheral module. More...
 
void CRC_Deinit (CRC_Type *base)
 Disables the CRC peripheral module. More...
 
static void CRC_GetDefaultConfig (crc_config_t *psConfig, crc_protocol_type_t eCrcProtocol)
 Provide default CRC protocol configuration. More...
 

CRC Configuration Interfaces

static void CRC_SetSeedValue (CRC_Type *base, uint32_t u32CrcSeedValue)
 Set the CRC seed value. More...
 
static void CRC_SetPolynomial (CRC_Type *base, uint32_t u32CrcPolynomial)
 Set the value of the polynomial for the CRC calculation. More...
 
static void CRC_SetWriteTransposeType (CRC_Type *base, crc_transpose_type_t eTransposeIn)
 Set CRC type of transpose of write data. More...
 
static void CRC_SetReadTransposeType (CRC_Type *base, crc_transpose_type_t eTransposeOut)
 Set CRC type of transpose of read data. More...
 
static void CRC_EnableComplementChecksum (CRC_Type *base, bool bEnable)
 Enable/Disable complement of read CRC checksum. More...
 
static void CRC_SetProtocolWidth (CRC_Type *base, crc_bits_t eCrcBits)
 Set bit width of CRC protocol. More...
 

CRC Write/Read Data Interfaces

void CRC_WriteData (CRC_Type *base, const uint8_t *pu8Data, uint32_t u32DataSize)
 Writes data to the CRC module. More...
 
static uint32_t CRC_Get32bitResult (CRC_Type *base)
 Reads the 32-bit checksum from the CRC module. More...
 
uint16_t CRC_Get16bitResult (CRC_Type *base)
 Reads a 16-bit checksum from the CRC module. More...
 

Data Structure Documentation

struct crc_config_t

This structure holds the configuration for the CRC protocol.

Data Fields

uint32_t u32CrcPolynomial
 CRC Polynomial, MSBit first. More...
 
uint32_t u32CrcSeedValue
 Starting checksum value.
 
bool bEnableComplementChecksum: 1
 Enable/Disable complement of read CRC checksum. More...
 
crc_transpose_type_t eTransposeIn: 2
 Select type of transpose of input data. More...
 
crc_transpose_type_t eTransposeOut: 2
 Select type of transpose of output data. More...
 
crc_bits_t eCrcBits: 1
 Select 16-bit or 32-bit CRC protocol. More...
 

Field Documentation

uint32_t crc_config_t::u32CrcPolynomial

Example polynomial: 0x1021 = 1_0000_0010_0001 = x^12+x^5+1

bool crc_config_t::bEnableComplementChecksum
crc_transpose_type_t crc_config_t::eTransposeIn
crc_transpose_type_t crc_config_t::eTransposeOut
crc_bits_t crc_config_t::eCrcBits

Macro Definition Documentation

#define FSL_CRC_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Version 2.0.0.

Enumeration Type Documentation

Enumerator
kCRC_Crc16 

CRC-16/MAXIM protocol.

kCRC_Crc16CCITT 

CRC-16-CCITT protocol.

kCRC_Crc16Kermit 

CRC-16/KERMIT protocol.

kCRC_Crc32 

CRC-32 protocol.

kCRC_Crc32Posix 

CRC-32/POSIX protocol.

enum crc_bits_t
Enumerator
kCRC_Bits16 

Generate 16-bit CRC code.

kCRC_Bits32 

Generate 32-bit CRC code.

Enumerator
kCRC_TransposeNone 

No transpose.

kCRC_TransposeBits 

Transpose bits in bytes.

kCRC_TransposeBitsAndBytes 

Transpose bytes and bits in bytes.

kCRC_TransposeBytes 

Transpose bytes.

Function Documentation

void CRC_Init ( CRC_Type *  base,
const crc_config_t psConfig 
)

This function enables the clock gate in the SIM module for the CRC peripheral. It also configures the CRC module and starts a checksum computation by writing the seed.

Parameters
baseCRC peripheral address.
psConfigCRC module configuration structure.
void CRC_Deinit ( CRC_Type *  base)

This function disables the clock gate in the SIM module for the CRC peripheral.

Parameters
baseCRC peripheral address.
static void CRC_GetDefaultConfig ( crc_config_t psConfig,
crc_protocol_type_t  eCrcProtocol 
)
inlinestatic

The purpose of this API is to initialize the configuration structure to default value for CRC_Init to use. Provides the configuration of commonly used CRC protocols. refer to _crc_protocol_type.

This is an example:

crc_config_t sConfig;
//LoadCRC-16/MAXIM protocol configuration.
CRC_Init(CRC, &sConfig);
*
Parameters
psConfigCRC protocol configuration structure.
eCrcProtocolCRC protocol type. refer to _crc_protocol_type
static void CRC_SetSeedValue ( CRC_Type *  base,
uint32_t  u32CrcSeedValue 
)
inlinestatic

This function is help to write a 16/32 bit CRC seed value.

Parameters
baseCRC peripheral address.
u32CrcSeedValueThe value of seed.
static void CRC_SetPolynomial ( CRC_Type *  base,
uint32_t  u32CrcPolynomial 
)
inlinestatic

Write a 16-bit or 32-bit polynomial to CRC Polynomial register for the CRC calculation.

Parameters
baseCRC peripheral address.
u32CrcPolynomialThe CRC polynomial.
static void CRC_SetWriteTransposeType ( CRC_Type *  base,
crc_transpose_type_t  eTransposeIn 
)
inlinestatic

This function help to configure CRC type of transpose of write data.

Parameters
baseCRC peripheral address.
eTransposeInType Of transpose for input. See _crc_transpose_type
static void CRC_SetReadTransposeType ( CRC_Type *  base,
crc_transpose_type_t  eTransposeOut 
)
inlinestatic

This function help to configure CRC type of transpose of read data.

Parameters
baseCRC peripheral address.
eTransposeOutType Of transpose for output. See _crc_transpose_type
static void CRC_EnableComplementChecksum ( CRC_Type *  base,
bool  bEnable 
)
inlinestatic

Set complement of read CRC checksum. Some CRC protocols require the final checksum to be XORed with 0xFFFFFFFF or 0xFFFF.

Parameters
baseCRC peripheral address.
bEnableTrue or false. True if the result shall be complement of the actual checksum.
static void CRC_SetProtocolWidth ( CRC_Type *  base,
crc_bits_t  eCrcBits 
)
inlinestatic

Selects 16-bit or 32-bit CRC protocol.

Parameters
baseCRC peripheral address.
eCrcBits16 or 32 bit CRC protocol. See _crc_bits
void CRC_WriteData ( CRC_Type *  base,
const uint8_t *  pu8Data,
uint32_t  u32DataSize 
)

Writes input data buffer bytes to the CRC data register. The configured type of transpose is applied.

Parameters
baseCRC peripheral address.
pu8DataInput data stream, MSByte in data[0].
u32DataSizeSize in bytes of the input data buffer.
static uint32_t CRC_Get32bitResult ( CRC_Type *  base)
inlinestatic

Reads the CRC data register (either an intermediate or the final checksum). The configured type of transpose and complement is applied.

Parameters
baseCRC peripheral address.
Returns
An intermediate or the final 32-bit checksum, after transpose and complement operations configured.
uint16_t CRC_Get16bitResult ( CRC_Type *  base)

Reads the CRC data register (either an intermediate or the final checksum). The configured type of transpose and complement is applied.

Parameters
baseCRC peripheral address.
Returns
An intermediate or the final 16-bit checksum, after transpose and complement operations configured.