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

Overview

Data Structures

struct  hal_crc_config_t
 CRC configuration structure. More...
 

Enumerations

enum  hal_crc_cfg_refin_t {
  KHAL_CrcInputNoRef = 0U,
  KHAL_CrcRefInput = 1U
}
 crcRefIn definitions. More...
 
enum  hal_crc_cfg_refout_t {
  KHAL_CrcOutputNoRef = 0U,
  KHAL_CrcRefOutput = 1U
}
 crcRefOut definitions. More...
 
enum  hal_crc_cfg_byteord_t {
  KHAL_CrcLSByteFirst = 0U,
  KHAL_CrcMSByteFirst = 1U
}
 crcByteOrder definitions. More...
 
enum  hal_crc_polynomial_t {
  KHAL_CrcPolynomial_CRC_8_CCITT = 0x103,
  KHAL_CrcPolynomial_CRC_16 = 0x1021,
  KHAL_CrcPolynomial_CRC_32 = 0x4C11DB7U
}
 CRC polynomials to use. More...
 

CRC

uint32_t HAL_CrcCompute (hal_crc_config_t *crcConfig, uint8_t *dataIn, uint32_t length)
 Compute CRC function. More...
 

Data Structure Documentation

struct hal_crc_config_t

Data Fields

hal_crc_cfg_refin_t crcRefIn
 CRC reflect input. More...
 
hal_crc_cfg_refout_t crcRefOut
 CRC reflect output. More...
 
hal_crc_cfg_byteord_t crcByteOrder
 CRC byte order. More...
 
uint32_t crcSeed
 CRC Seed value. More...
 
uint32_t crcPoly
 CRC Polynomial value. More...
 
uint32_t crcXorOut
 XOR mask for CRC result (for no mask, should be 0). More...
 
uint8_t complementChecksum
 wether output the complement checksum. More...
 
uint8_t crcSize
 Number of CRC octets, 2 mean use CRC16, 4 mean use CRC32. More...
 
uint8_t crcStartByte
 Start CRC with this byte position. More...
 

Field Documentation

hal_crc_cfg_refin_t hal_crc_config_t::crcRefIn

See "hal_crc_cfg_refin_t".

hal_crc_cfg_refout_t hal_crc_config_t::crcRefOut

See "hal_crc_cfg_refout_t".

hal_crc_cfg_byteord_t hal_crc_config_t::crcByteOrder

See "hal_crc_cfg_byteord_t".

uint32_t hal_crc_config_t::crcSeed

Initial value for CRC LFSR.

uint32_t hal_crc_config_t::crcPoly
uint32_t hal_crc_config_t::crcXorOut
uint8_t hal_crc_config_t::complementChecksum
uint8_t hal_crc_config_t::crcSize
uint8_t hal_crc_config_t::crcStartByte

Byte #0 is the first byte of Sync Address.

Enumeration Type Documentation

Enumerator
KHAL_CrcInputNoRef 

Do not manipulate input data stream.

KHAL_CrcRefInput 

Reflect each byte in the input stream bitwise.

Enumerator
KHAL_CrcOutputNoRef 

Do not manipulate CRC result.

KHAL_CrcRefOutput 

CRC result is to be reflected bitwise (operated on entire word).

Enumerator
KHAL_CrcLSByteFirst 

Byte order of the CRC LS Byte first.

KHAL_CrcMSByteFirst 

Bit order of the CRC MS Byte first.

Enumerator
KHAL_CrcPolynomial_CRC_8_CCITT 

x^8+x^2+x^1+1

KHAL_CrcPolynomial_CRC_16 

x^16+x^12+x^5+1

KHAL_CrcPolynomial_CRC_32 

x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1

Function Documentation

uint32_t HAL_CrcCompute ( hal_crc_config_t crcConfig,
uint8_t *  dataIn,
uint32_t  length 
)

The function computes the CRC.

* config = (hal_crc_config_t) {
* .crcSize = 4,
* .crcStartByte = 0,
* .crcRefIn = KHAL_CrcInputNoRef,
* .crcRefOut = KHAL_CrcOutputNoRef,
* .crcByteOrder = KHAL_CrcMSByteFirst,
* .complementChecksum = true,
* .crcSeed = 0xFFFFFFFF,
* .crcXorOut = 0xFFFFFFFF,
* };
*
* res = HAL_CrcCompute(&config, (uint8_t *) pattern, strlen(pattern));
*
Note
The settings for compute CRC are taken from the passed CRC_config_t structure.
Parameters
crcConfigconfiguration structure.
dataIninput data buffer.
lengthinput data buffer size.
Return values
ComputedCRC value.