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

Peripheral features and how this peripheral works

A Cyclic Redundancy Check (CRC) or polynomial code checksum is a hash function designed to detect data integrity. The 88MW320/322 CRC unit calculates a short, fixed-length binary sequence, known as the CRC code. For each block of data, CRC code and original data are sent or stored together. When a block of data is used, the same CRC calculation is processed. If the new CRC does not match the one pre-calculated earlier in the block of data, then the block contains a data error and the device may take corrective action, such as resending or requesting the block again. Otherwise the data is assumed to be error free (though, with some small probability, it may contain undetected errors; this is the fundamental nature of error-checking).

Features

How this peripheral works

  1. Configure the CRC MODE properly, enable CRC
  2. Write stream in and waiting for calculation finished
  3. Get CRC calculation result

How this driver is designed to make this peripheral works.

  1. Call CRC_Init() function to initialize the CRC module
  2. Call CRC_SetMode() to select the work mode.
  3. Call CRC_Calculate() to calculate the CRC for input data block.

Enumerations

enum  crc_mode_t {
  kCRC_16BitsCcitt = 0U,
  kCRC_16BitsIbm = 1U,
  kCRC_16BitsT10Dif = 2U,
  kCRC_32BitsIeee = 3U,
  kCRC_16BitsDnp = 4U
}
 CRC mode type definition. More...
 

Driver version

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

Initialization Interfaces

void CRC_Init (CRC_Type *base)
 Initializes CRC module. More...
 
void CRC_Deinit (CRC_Type *base)
 Disable the interrupt and clear all the interrupts. More...
 

CRC Operation Interfaces

static void CRC_SetMode (CRC_Type *base, crc_mode_t crcMode)
 Set CRC mode. More...
 
static void CRC_Enable (CRC_Type *base, bool enable)
 Enable the CRC module. More...
 
static void CRC_FeedData (CRC_Type *base, uint32_t data)
 Feed data in CRC stream. More...
 
static void CRC_SetStreamLen (CRC_Type *base, uint32_t strLen)
 Set CRC stream length. More...
 
static uint32_t CRC_GetResult (CRC_Type *base)
 Get CRC result. More...
 
uint32_t CRC_Calculate (CRC_Type *base, const uint8_t *dataStr, uint32_t dataLen)
 Calculate the CRC value for input data block. More...
 

Interrupt Control Interfaces

static void CRC_EnableInterrupt (CRC_Type *base)
 Enable the CRC Interrupt. More...
 
static void CRC_DisableInterrupt (CRC_Type *base)
 Disable the CRC Interrupt. More...
 
static void CRC_ClearInterruptStatus (CRC_Type *base)
 brief Clears interrupt flags. More...
 
static bool CRC_GetInterruptStatus (CRC_Type *base)
 Get base interrupt status. More...
 
static bool CRC_GetRawInterruptStatus (CRC_Type *base)
 Get CRC raw interrupt status. More...
 

Enumeration Type Documentation

enum crc_mode_t
Enumerator
kCRC_16BitsCcitt 

CRC mode: CRC-16-CCITT.

kCRC_16BitsIbm 

CRC mode: CRC-16-IBM.

kCRC_16BitsT10Dif 

CRC mode: CRC-16-T10-DIF.

kCRC_32BitsIeee 

CRC mode: CRC-32-IEEE.

kCRC_16BitsDnp 

CRC mode: CRC-16-DNP.

Function Documentation

void CRC_Init ( CRC_Type *  base)

Call this function to initialize the CRC module.

Parameters
baseCRC peripheral base address
void CRC_Deinit ( CRC_Type *  base)
Parameters
baseCRC peripheral base address
static void CRC_SetMode ( CRC_Type *  base,
crc_mode_t  crcMode 
)
inlinestatic
Parameters
baseCRC peripheral base address.
crcModeThe CRC work mode to set.
static void CRC_Enable ( CRC_Type *  base,
bool  enable 
)
inlinestatic

This function enable/disables the CRC.

Parameters
baseCRC peripheral base address.
enableUse true to enable, false to disable.
static void CRC_FeedData ( CRC_Type *  base,
uint32_t  data 
)
inlinestatic
Parameters
baseCRC peripheral address.
datainput data.
static void CRC_SetStreamLen ( CRC_Type *  base,
uint32_t  strLen 
)
inlinestatic
Parameters
baseCRC peripheral address.
strLenstream length in byte.
static uint32_t CRC_GetResult ( CRC_Type *  base)
inlinestatic
Parameters
baseCRC peripheral base address.
Returns
CRC calculation result.
uint32_t CRC_Calculate ( CRC_Type *  base,
const uint8_t *  dataStr,
uint32_t  dataLen 
)
Parameters
baseCRC peripheral base address.
dataStrinput data stream.
dataLendata length in byte.
Returns
CRC calculation result.
static void CRC_EnableInterrupt ( CRC_Type *  base)
inlinestatic
Parameters
baseCRC peripheral base address.
static void CRC_DisableInterrupt ( CRC_Type *  base)
inlinestatic
Parameters
baseCRC peripheral base address.
static void CRC_ClearInterruptStatus ( CRC_Type *  base)
inlinestatic
Parameters
baseCRC peripheral base address.
static bool CRC_GetInterruptStatus ( CRC_Type *  base)
inlinestatic
Parameters
baseCRC peripheral base address.
Returns
true if interrupt flag is asserted, else false.
static bool CRC_GetRawInterruptStatus ( CRC_Type *  base)
inlinestatic

This function is similar with CRC_GetInterruptStatus, the only difference is, the raw interrupt status is not affected by interrupt enable status.

Parameters
baseCRC peripheral base address.
Returns
true if CRC status is asserted, else false.