MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Crc

Overview

Data Structures

struct  crc_config_t
 CRC protocol configuration. More...
 

Macros

#define CRC_DRIVER_USE_CRC16_CCIT_FALSE_AS_DEFAULT   1
 Default configuration structure filled by CRC_GetDefaultConfig(). More...
 

Enumerations

enum  crc_bits_t {
  kCrcBits16 = 0U,
  kCrcBits32 = 1U
}
 CRC bit width. More...
 
enum  crc_result_t {
  kCrcFinalChecksum = 0U,
  kCrcIntermediateChecksum = 1U
}
 CRC result type. More...
 

Functions

void CRC_Init (CRC_Type *base, const crc_config_t *config)
 Enables and configures the CRC peripheral module. More...
 
static void CRC_Deinit (CRC_Type *base)
 Disables the CRC peripheral module. More...
 
void CRC_GetDefaultConfig (crc_config_t *config)
 Loads default values to the CRC protocol configuration structure. More...
 
void CRC_WriteData (CRC_Type *base, const uint8_t *data, size_t dataSize)
 Writes data to the CRC module. More...
 
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...
 

Driver version

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

Data Structure Documentation

struct crc_config_t

This structure holds the configuration for the CRC protocol.

Data Fields

uint32_t polynomial
 CRC Polynomial, MSBit first. More...
 
uint32_t seed
 Starting checksum value.
 
bool reflectIn
 Reflect bits on input. More...
 
bool reflectOut
 Reflect bits on output. More...
 
bool complementChecksum
 True if the result shall be complement of the actual checksum. More...
 
crc_bits_t crcBits
 Selects 16- or 32- bit CRC protocol. More...
 
crc_result_t crcResult
 Selects final or intermediate checksum return from CRC_Get16bitResult() or CRC_Get32bitResult()
 

Field Documentation

uint32_t crc_config_t::polynomial

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

bool crc_config_t::reflectIn
bool crc_config_t::reflectOut
bool crc_config_t::complementChecksum
crc_bits_t crc_config_t::crcBits

Macro Definition Documentation

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

Version 2.0.1.

Current version: 2.0.1

Change log:

  • Version 2.0.1
    • move DATA and DATALL macro definition from header file to source file
#define CRC_DRIVER_USE_CRC16_CCIT_FALSE_AS_DEFAULT   1

Use CRC16-CCIT-FALSE as defeault.

Enumeration Type Documentation

enum crc_bits_t
Enumerator
kCrcBits16 

Generate 16-bit CRC code.

kCrcBits32 

Generate 32-bit CRC code.

Enumerator
kCrcFinalChecksum 

CRC data register read value is the final checksum.

Reflect out and final xor protocol features are applied.

kCrcIntermediateChecksum 

CRC data register read value is intermediate checksum (raw value).

Reflect out and final xor protocol feature are not applied. Intermediate checksum can be used as a seed for CRC_Init() to continue adding data to this checksum.

Function Documentation

void CRC_Init ( CRC_Type *  base,
const crc_config_t config 
)

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.
configCRC module configuration structure.
static void CRC_Deinit ( CRC_Type *  base)
inlinestatic

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

Parameters
baseCRC peripheral address.
void CRC_GetDefaultConfig ( crc_config_t config)

Loads default values to the CRC protocol configuration structure. The default values are as follows.

* config->polynomial = 0x1021;
* config->seed = 0xFFFF;
* config->reflectIn = false;
* config->reflectOut = false;
* config->complementChecksum = false;
* config->crcBits = kCrcBits16;
* config->crcResult = kCrcFinalChecksum;
*
Parameters
configCRC protocol configuration structure.
void CRC_WriteData ( CRC_Type *  base,
const uint8_t *  data,
size_t  dataSize 
)

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

Parameters
baseCRC peripheral address.
dataInput data stream, MSByte in data[0].
dataSizeSize in bytes of the input data buffer.
uint32_t CRC_Get32bitResult ( 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 32-bit checksum, after configured transpose and complement operations.
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 configured transpose and complement operations.