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

Overview

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.

Data Structures

struct  crc_config_t
 CRC protocol configuration. More...
 

Macros

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

Enumerations

enum  crc_type_t {
  kCRC_Crc16 = CRC_CONTROL_CRCMOD(0),
  kCRC_Crc32 = CRC_CONTROL_CRCMOD(1)
}
 CRC type. More...
 
enum  crc_endian_t {
  kCRC_MsbFirst = CRC_CONTROL_CRCINV(0),
  kCRC_LsbFirst = CRC_CONTROL_CRCINV(1)
}
 CRC INV selection. More...
 

Functions

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

Data Structure Documentation

struct crc_config_t

This structure holds the configuration for the CRC protocol.

Data Fields

bool crcEnable: 1
 Block Enable or Disable. More...
 
crc_type_t crcMode
 Select CRC protocol. More...
 
crc_endian_t crcEndian
 Select MSB or ILSB first data processing. More...
 

Field Documentation

bool crc_config_t::crcEnable
crc_type_t crc_config_t::crcMode
crc_endian_t crc_config_t::crcEndian

Macro Definition Documentation

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

Enumeration Type Documentation

enum crc_type_t

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.

Function Documentation

void CRC_Init ( CRC_Type *  base)

This function enables the clock gate for the CRC peripheral.

Parameters
baseCRC peripheral address.
void CRC_Deinit ( CRC_Type *  base)

This function disables the clock gate for the CRC peripheral.

Parameters
baseCRC peripheral address.
void CRC_GetDefaultConfig ( crc_config_t config)

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:

config->enable = true;
config->crcMode = kCRC_Crc16;
config->crcEndian = kCRC_LsbFirst;
*

This is an example:

crc_config_t crc16Config;
//Load CRC-16 protocol configuration.
CRC_GetDefaultConfig(&crc16Config);
CRC_SetConfig(CRC, crc16Config);
*
Parameters
configCRC 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
baseCRC peripheral address.
configCRC 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
baseCRC peripheral address.
crcPreloadThe value of seed.
void CRC_WriteData ( CRC_Type *  base,
const uint8_t *  buffer,
uint32_t  len 
)

This function writes data to CRC.

Parameters
baseCRC peripheral address.
bufferdata message to be checked.
lenlength of buffer.
static uint32_t CRC_GetResult ( CRC_Type *  base)
inlinestatic

Reads the CRC data register (either an intermediate or the final checksum).

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