Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the CRC HAL driver.

Files

file  fsl_crc_hal.h
 

Enumerations

enum  crc_status_t {
  kStatus_CRC_Success = 0U,
  kStatus_CRC_InvalidArgument = 1U,
  kStatus_CRC_Failed = 2U
}
 

Definitions More...

 
enum  crc_transpose_t {
  kCrcNoTranspose = 0U,
  kCrcTransposeBits = 1U,
  kCrcTransposeBoth = 2U,
  kCrcTransposeBytes = 3U
}
 Define type of enumerating transpose modes for CRC peripheral. More...
 
enum  crc_prot_width_t {
  kCrc16Bits = 0U,
  kCrc32Bits = 1U
}
 Define type of enumerating CRC protocol widths for CRC peripheral. More...
 

CRC-related feature APIs


API

void CRC_HAL_Init (CRC_Type *base)
 This function initializes the module to a known state. More...
 
static uint32_t CRC_HAL_GetDataReg (CRC_Type *base)
 Returns the current CRC result from the data register. More...
 
static uint16_t CRC_HAL_GetDataHReg (CRC_Type *base)
 Returns the upper 16 bits of the current CRC result from the data register. More...
 
static uint16_t CRC_HAL_GetDataLReg (CRC_Type *base)
 Returns the lower 16 bits of the current CRC result from the data register. More...
 
static void CRC_HAL_SetDataReg (CRC_Type *base, uint32_t value)
 Sets the CRC data register (4 bytes). More...
 
static void CRC_HAL_SetDataHReg (CRC_Type *base, uint16_t value)
 Sets the CRC data register (upper 2 bytes). More...
 
static void CRC_HAL_SetDataLReg (CRC_Type *base, uint16_t value)
 Sets the CRC data register (lower 2 bytes). More...
 
static void CRC_HAL_SetDataHLReg (CRC_Type *base, uint8_t value)
 Sets the CRC data register (HL byte). More...
 
static void CRC_HAL_SetDataHUReg (CRC_Type *base, uint8_t value)
 Sets the CRC data register (HU byte). More...
 
static void CRC_HAL_SetDataLLReg (CRC_Type *base, uint8_t value)
 Sets the CRC data register (LL byte). More...
 
static void CRC_HAL_SetDataLUReg (CRC_Type *base, uint8_t value)
 Sets the CRC data register (LU byte). More...
 
static uint32_t CRC_HAL_GetPolyReg (CRC_Type *base)
 Returns the polynomial register value. More...
 
static uint16_t CRC_HAL_GetPolyHReg (CRC_Type *base)
 Returns the upper 16 bits of polynomial register. More...
 
static uint16_t CRC_HAL_GetPolyLReg (CRC_Type *base)
 Returns the lower 16 bits of polynomial register. More...
 
static void CRC_HAL_SetPolyReg (CRC_Type *base, uint32_t value)
 Sets the polynomial register. More...
 
static void CRC_HAL_SetPolyHReg (CRC_Type *base, uint16_t value)
 Sets the upper 16 bits of polynomial register. More...
 
static void CRC_HAL_SetPolyLReg (CRC_Type *base, uint16_t value)
 Sets the lower 16 bits of polynomial register. More...
 
static uint32_t CRC_HAL_GetCtrlReg (CRC_Type *base)
 Returns the CRC control register. More...
 
static void CRC_HAL_SetCtrlReg (CRC_Type *base, uint32_t value)
 Sets the CRC control register. More...
 
static bool CRC_HAL_GetSeedOrDataMode (CRC_Type *base)
 Gets the CRC seed mode. More...
 
static void CRC_HAL_SetSeedOrDataMode (CRC_Type *base, bool enable)
 Sets the CRC seed mode. More...
 
static crc_transpose_t CRC_HAL_GetWriteTranspose (CRC_Type *base)
 Gets the CRC transpose type for writes. More...
 
static void CRC_HAL_SetWriteTranspose (CRC_Type *base, crc_transpose_t transp)
 Sets the CRC transpose type for writes. More...
 
static crc_transpose_t CRC_HAL_GetReadTranspose (CRC_Type *base)
 Gets the CRC transpose type for reads. More...
 
static void CRC_HAL_SetReadTranspose (CRC_Type *base, crc_transpose_t transp)
 Sets the CRC transpose type for reads. More...
 
static bool CRC_HAL_GetXorMode (CRC_Type *base)
 Gets the CRC XOR mode. More...
 
static void CRC_HAL_SetXorMode (CRC_Type *base, bool enable)
 Sets the CRC XOR mode. More...
 
static crc_prot_width_t CRC_HAL_GetProtocolWidth (CRC_Type *base)
 Gets the CRC protocol width. More...
 
static void CRC_HAL_SetProtocolWidth (CRC_Type *base, crc_prot_width_t width)
 Sets the CRC protocol width. More...
 
uint32_t CRC_HAL_GetCrc32 (CRC_Type *base, uint32_t data, bool newSeed, uint32_t seed)
 CRC_HAL_GetCrc32. More...
 
uint32_t CRC_HAL_GetCrc16 (CRC_Type *base, uint16_t data, bool newSeed, uint32_t seed)
 CRC_HAL_GetCrc16. More...
 
uint32_t CRC_HAL_GetCrc8 (CRC_Type *base, uint8_t data, bool newSeed, uint32_t seed)
 CRC_HAL_GetCrc8. More...
 
uint32_t CRC_HAL_GetCrcResult (CRC_Type *base)
 CRC_HAL_GetCrcResult. More...
 

Enumeration Type Documentation

CRC status return codes.

Enumerator
kStatus_CRC_Success 

Success.

kStatus_CRC_InvalidArgument 

Invalid argument existed.

kStatus_CRC_Failed 

Execution failed.

Enumerator
kCrcNoTranspose 

No transposition.

kCrcTransposeBits 

Bits in bytes are transposed; bytes are not transposed.

kCrcTransposeBoth 

Both bits in bytes and bytes are transposed.

kCrcTransposeBytes 

Only bytes are transposed; no bits in a byte are transposed.

Enumerator
kCrc16Bits 

16-bit CRC protocol.

kCrc32Bits 

32-bit CRC protocol.

Function Documentation

void CRC_HAL_Init ( CRC_Type *  base)
Parameters
baseThe CRC peripheral base address.
static uint32_t CRC_HAL_GetDataReg ( CRC_Type *  base)
inlinestatic
Parameters
baseThe CRC peripheral base address.
Returns
Returns a 32-bit value.
static uint16_t CRC_HAL_GetDataHReg ( CRC_Type *  base)
inlinestatic
Parameters
baseThe CRC peripheral base address.
Returns
Returns a 16-bit value.
static uint16_t CRC_HAL_GetDataLReg ( CRC_Type *  base)
inlinestatic
Parameters
baseThe CRC peripheral base address.
Returns
Returns a 16-bit value.
static void CRC_HAL_SetDataReg ( CRC_Type *  base,
uint32_t  value 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
valueNew data for CRC computation. This parameter is a 32-bit value.
static void CRC_HAL_SetDataHReg ( CRC_Type *  base,
uint16_t  value 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
valueNew data for CRC computation. This parameter is a 16-bit value.
static void CRC_HAL_SetDataLReg ( CRC_Type *  base,
uint16_t  value 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
valueNew data for CRC computation. This parameter is a 16-bit value.
static void CRC_HAL_SetDataHLReg ( CRC_Type *  base,
uint8_t  value 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
valueNew data for CRC computation. This parameter is a 8-bit value.
static void CRC_HAL_SetDataHUReg ( CRC_Type *  base,
uint8_t  value 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
valueNew data for CRC computation. This parameter is a 8-bit value.
static void CRC_HAL_SetDataLLReg ( CRC_Type *  base,
uint8_t  value 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
valueNew data for CRC computation. This parameter is a 8-bit value.
static void CRC_HAL_SetDataLUReg ( CRC_Type *  base,
uint8_t  value 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
valueNew data for CRC computation. This parameter is a 8-bit value.
static uint32_t CRC_HAL_GetPolyReg ( CRC_Type *  base)
inlinestatic
Parameters
baseThe CRC peripheral base address.
Returns
Returns a 32-bit value.
static uint16_t CRC_HAL_GetPolyHReg ( CRC_Type *  base)
inlinestatic
Parameters
baseThe CRC peripheral base address.
Returns
Returns a 16-bit value.
static uint16_t CRC_HAL_GetPolyLReg ( CRC_Type *  base)
inlinestatic
Parameters
baseThe CRC peripheral base address.
Returns
Returns a 16-bit value.
static void CRC_HAL_SetPolyReg ( CRC_Type *  base,
uint32_t  value 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
valuePolynomial value. This parameter is a 32-bit value.
static void CRC_HAL_SetPolyHReg ( CRC_Type *  base,
uint16_t  value 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
valuePolynomial value. This parameter is a 16-bit value.
static void CRC_HAL_SetPolyLReg ( CRC_Type *  base,
uint16_t  value 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
valuePolynomial value. This parameter is a 16-bit value.
static uint32_t CRC_HAL_GetCtrlReg ( CRC_Type *  base)
inlinestatic
Parameters
baseThe CRC peripheral base address.
Returns
Returns a 32-bit value.
static void CRC_HAL_SetCtrlReg ( CRC_Type *  base,
uint32_t  value 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
valueControl register value. This parameter is a 32-bit value.
static bool CRC_HAL_GetSeedOrDataMode ( CRC_Type *  base)
inlinestatic
Parameters
baseThe CRC peripheral base address.
Returns
CRC seed mode -true: Seed mode is enabled -false: Data mode is enabled
static void CRC_HAL_SetSeedOrDataMode ( CRC_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
enableEnable or disable seed mode. -true: use CRC data register for seed values -false: use CRC data register for data values
static crc_transpose_t CRC_HAL_GetWriteTranspose ( CRC_Type *  base)
inlinestatic
Parameters
baseThe CRC peripheral base address.
Returns
CRC input transpose type for writes.
static void CRC_HAL_SetWriteTranspose ( CRC_Type *  base,
crc_transpose_t  transp 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
transpThe CRC input transpose type.
static crc_transpose_t CRC_HAL_GetReadTranspose ( CRC_Type *  base)
inlinestatic
Parameters
baseThe CRC peripheral base address.
Returns
CRC output transpose type.
static void CRC_HAL_SetReadTranspose ( CRC_Type *  base,
crc_transpose_t  transp 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
transpThe CRC output transpose type.
static bool CRC_HAL_GetXorMode ( CRC_Type *  base)
inlinestatic

Some CRC protocols require the final checksum to be XORed with 0xFFFFFFFF or 0xFFFF. XOR mode enables "on the fly" complementing of read data.

Parameters
baseThe CRC peripheral base address.
Returns
CRC XOR mode -true: XOR mode is enabled -false: XOR mode is disabled
static void CRC_HAL_SetXorMode ( CRC_Type *  base,
bool  enable 
)
inlinestatic

Some CRC protocols require the final checksum to be XORed with 0xFFFFFFFF or 0xFFFF. XOR mode enables "on the fly" complementing of read data.

Parameters
baseThe CRC peripheral base address.
enableEnable or disable XOR mode.
static crc_prot_width_t CRC_HAL_GetProtocolWidth ( CRC_Type *  base)
inlinestatic
Parameters
baseThe CRC peripheral base address.
Returns
CRC protocol width -kCrc16Bits: 16-bit CRC protocol -kCrc32Bits: 32-bit CRC protocol
static void CRC_HAL_SetProtocolWidth ( CRC_Type *  base,
crc_prot_width_t  width 
)
inlinestatic
Parameters
baseThe CRC peripheral base address.
widthThe CRC protocol width -kCrc16Bits: 16-bit CRC protocol -kCrc32Bits: 32-bit CRC protocol
uint32_t CRC_HAL_GetCrc32 ( CRC_Type *  base,
uint32_t  data,
bool  newSeed,
uint32_t  seed 
)

This method appends 32-bit data to the current CRC calculation and returns new result. If the newSeed is true, seed set and result are calculated from the seed new value (new CRC calculation).

Parameters
baseThe CRC peripheral base address.
datainput data for CRC calculation
newSeedSets new CRC calculation.
  • true: New seed set and used for new calculation.
  • false: seed argument ignored, continues old calculation.
seedNew seed if newSeed is true, else ignored
Returns
new CRC result.
uint32_t CRC_HAL_GetCrc16 ( CRC_Type *  base,
uint16_t  data,
bool  newSeed,
uint32_t  seed 
)

This method appends the 16-bit data to the current CRC calculation and returns a new result. If the newSeed is true, seed set and result are calculated from the seed new value (new CRC calculation).

Parameters
baseThe CRC peripheral base address.
datainput data for CRC calculation
newSeedSets new CRC calculation.
  • true: New seed set and used for new calculation.
  • false: seed argument ignored, continues old calculation.
seedNew seed if newSeed is true, else ignored
Returns
new CRC result.
uint32_t CRC_HAL_GetCrc8 ( CRC_Type *  base,
uint8_t  data,
bool  newSeed,
uint32_t  seed 
)

This method appends the 8-bit data to the current CRC calculation and returns the new result. If the newSeed is true, seed set and result are calculated from the seed new value (new CRC calculation).

Parameters
baseThe CRC peripheral base address.
datainput data for CRC calculation
newSeedSets new CRC calculation.
  • true: New seed set and used for new calculation.
  • false: seed argument ignored, continues old calculation.
seedNew seed if newSeed is true, else ignored
Returns
new CRC result.
uint32_t CRC_HAL_GetCrcResult ( CRC_Type *  base)

This method returns the current result of the CRC calculation. The result is the ReadTranspose dependent.

Parameters
baseThe CRC peripheral base address.
Returns
result of CRC calculation.