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

Overview

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.

Modules

 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 parameters configuration . More...
 

Enumerations

enum  crc_seed_value_t {
  kCRC_Crc16Kermit = 0x0000U,
  kCRC_CrcA = 0xC6C6U,
  kCRC_Crc16Riello = 0xB2AAU,
  kCRC_Crc16Tms37157 = 0x89ECU,
  kCRC_Crc16Mcrf4xx = 0xFFFFU,
  kCRC_Crc16CCITT = 0xFFFFU,
  kCRC_Crc16Augccitt = 0x1D0FU,
  kCRC_Crc16Xmodem = 0x0000U
}
 CRC seed value. 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...
 
void CRC_GetDefaultConfig (crc_config_t *psConfig)
 Provide default CRC seed value configuration. More...
 

CRC Write/Read Data Interfaces

void CRC_SetSeedValue (CRC_Type *base, uint16_t u16CrcSeedValue)
 Set the CRC seed value. More...
 
void CRC_WriteData (CRC_Type *base, const uint8_t *pu8Data, uint16_t u16DataSize, bool bRefin)
 Writes data to the CRC module. More...
 
uint16_t CRC_Get16bitResult (CRC_Type *base, bool bRefOut)
 Reads a 16-bit checksum from the CRC module. More...
 
static uint8_t CRC_TransposeByte (CRC_Type *base, uint8_t u8Input)
 CRC transpose module. More...
 

Data Structure Documentation

struct crc_config_t

This structure holds the configuration for the CRC required parameters.

Data Fields

uint16_t u16CrcSeedValue
 Starting checksum value.
 
bool bSetSeed
 Set the seed value to registers only when this value is true.
 

Macro Definition Documentation

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

Enumeration Type Documentation

Enumerator
kCRC_Crc16Kermit 

CRC-16/KERMIT protocol.

kCRC_CrcA 

CRC/CRCA protocol.

kCRC_Crc16Riello 

CRC-16/RIELLO protocol.

kCRC_Crc16Tms37157 

CRC-16/TMS37157 protocol.

kCRC_Crc16Mcrf4xx 

CRC-16-MCRF4XX protocol.

kCRC_Crc16CCITT 

CRC-16-CCITT protocol.

kCRC_Crc16Augccitt 

CRC-16/AUG-CCITT protocol.

kCRC_Crc16Xmodem 

CRC-16/XMODEM protocol.

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.
void CRC_GetDefaultConfig ( crc_config_t psConfig)

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 seed values. refer to crc_seed_value_t.

Parameters
psConfigCRC parameters configuration structure.
void CRC_SetSeedValue ( CRC_Type *  base,
uint16_t  u16CrcSeedValue 
)

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

Parameters
baseCRC peripheral address.
u16CrcSeedValueThe value of seed.
void CRC_WriteData ( CRC_Type *  base,
const uint8_t *  pu8Data,
uint16_t  u16DataSize,
bool  bRefin 
)

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].
u16DataSizeSize in bytes of the input data buffer.
bRefinInvert when input calculations.
uint16_t CRC_Get16bitResult ( CRC_Type *  base,
bool  bRefOut 
)

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.
bRefOutInvert the calculated CRC value as a whole.
Returns
A 16-bit checksum with or without transposed configuration.
static uint8_t CRC_TransposeByte ( CRC_Type *  base,
uint8_t  u8Input 
)
inlinestatic

The CRC module provides an additional feature to transpose data (invert bit order)

Parameters
baseCRC peripheral address.
u8InputAn 8-bit input data.