S32 SDK

Detailed Description

Cyclic Redundancy Check Hardware Abstraction Layer.

This section describes the programming interface of the CRC HAL.

Enumerations

enum  crc_transpose_t { CRC_TRANSPOSE_NONE = 0x00U, CRC_TRANSPOSE_BITS = 0x01U, CRC_TRANSPOSE_BITS_AND_BYTES = 0x02U, CRC_TRANSPOSE_BYTES = 0x03U }
 CRC type of transpose of read write data Implements : crc_transpose_t_Class. More...
 
enum  crc_bit_width_t { CRC_BITS_16 = 0U, CRC_BITS_32 = 1U }
 CRC bit width Implements : crc_bit_width_t_Class. More...
 

CRC HAL API

void CRC_HAL_Init (CRC_Type *const base)
 Initializes the CRC module. More...
 
uint32_t CRC_HAL_GetCrc32 (CRC_Type *const base, uint32_t data, bool newSeed, uint32_t seed)
 Appends 32-bit data to the current CRC calculation and returns new result. More...
 
uint32_t CRC_HAL_GetCrc16 (CRC_Type *const base, uint16_t data, bool newSeed, uint32_t seed)
 Appends 16-bit data to the current CRC calculation and returns new result. More...
 
uint32_t CRC_HAL_GetCrc8 (CRC_Type *const base, uint8_t data, bool newSeed, uint32_t seed)
 Appends 8-bit data to the current CRC calculation and returns new result. More...
 
uint32_t CRC_HAL_GetCrcResult (const CRC_Type *const base)
 Returns the current result of the CRC calculation. More...
 
static uint32_t CRC_HAL_GetDataReg (const CRC_Type *const base)
 Gets the current CRC result. More...
 
static void CRC_HAL_SetDataReg (CRC_Type *const base, uint32_t value)
 Sets the 32 bits of CRC data register. More...
 
static uint16_t CRC_HAL_GetDataHReg (const CRC_Type *const base)
 Gets the upper 16 bits of the current CRC result. More...
 
static void CRC_HAL_SetDataHReg (CRC_Type *const base, uint16_t value)
 Sets the upper 16 bits of CRC data register. More...
 
static uint16_t CRC_HAL_GetDataLReg (const CRC_Type *const base)
 Gets the lower 16 bits of the current CRC result. More...
 
static void CRC_HAL_SetDataLReg (CRC_Type *const base, uint16_t value)
 Sets the lower 16 bits of CRC data register. More...
 
static void CRC_HAL_SetDataHUReg (CRC_Type *const base, uint8_t value)
 Sets the High Upper Byte - HU. More...
 
static void CRC_HAL_SetDataHLReg (CRC_Type *const base, uint8_t value)
 Sets the High Lower Byte - HL. More...
 
static void CRC_HAL_SetDataLUReg (CRC_Type *const base, uint8_t value)
 Sets the Low Upper Byte - LU. More...
 
static void CRC_HAL_SetDataLLReg (CRC_Type *const base, uint8_t value)
 Sets the Low Lower Byte - LL. More...
 
static uint32_t CRC_HAL_GetPolyReg (const CRC_Type *const base)
 Gets the polynomial register value. More...
 
static void CRC_HAL_SetPolyReg (CRC_Type *const base, uint32_t value)
 Sets the polynomial register. More...
 
static uint16_t CRC_HAL_GetPolyHReg (const CRC_Type *const base)
 Gets the upper 16 bits of polynomial register. More...
 
static void CRC_HAL_SetPolyHReg (CRC_Type *const base, uint16_t value)
 Sets the upper 16 bits of polynomial register. More...
 
static uint16_t CRC_HAL_GetPolyLReg (const CRC_Type *const base)
 Gets the lower 16 bits of polynomial register. More...
 
static void CRC_HAL_SetPolyLReg (CRC_Type *const base, uint16_t value)
 Sets the lower 16 bits of polynomial register. More...
 
static bool CRC_HAL_GetSeedOrDataMode (const CRC_Type *const base)
 Gets the CRC_DATA register mode. More...
 
static void CRC_HAL_SetSeedOrDataMode (CRC_Type *const base, bool enable)
 Sets the CRC_DATA register mode. More...
 
static bool CRC_HAL_GetFXorMode (const CRC_Type *const base)
 Gets complement read of CRC data register. More...
 
static void CRC_HAL_SetFXorMode (CRC_Type *const base, bool enable)
 Sets complement read of CRC data register. More...
 
static crc_bit_width_t CRC_HAL_GetProtocolWidth (const CRC_Type *const base)
 Gets the CRC protocol width. More...
 
static void CRC_HAL_SetProtocolWidth (CRC_Type *const base, crc_bit_width_t width)
 Sets the CRC protocol width. More...
 
static crc_transpose_t CRC_HAL_GetWriteTranspose (const CRC_Type *const base)
 Gets the CRC transpose type for writes. More...
 
static void CRC_HAL_SetWriteTranspose (CRC_Type *const base, crc_transpose_t transp)
 Sets the CRC transpose type for writes. More...
 
static crc_transpose_t CRC_HAL_GetReadTranspose (const CRC_Type *const base)
 Gets the CRC transpose type for reads. More...
 
static void CRC_HAL_SetReadTranspose (CRC_Type *const base, crc_transpose_t transp)
 Sets the CRC transpose type for reads. More...
 

Enumeration Type Documentation

CRC bit width Implements : crc_bit_width_t_Class.

Enumerator
CRC_BITS_16 

Generate 16-bit CRC code

CRC_BITS_32 

Generate 32-bit CRC code

Definition at line 54 of file crc_hal.h.

CRC type of transpose of read write data Implements : crc_transpose_t_Class.

Enumerator
CRC_TRANSPOSE_NONE 

No transpose

CRC_TRANSPOSE_BITS 

Transpose bits in bytes

CRC_TRANSPOSE_BITS_AND_BYTES 

Transpose bytes and bits in bytes

CRC_TRANSPOSE_BYTES 

Transpose bytes

Definition at line 42 of file crc_hal.h.

Function Documentation

uint32_t CRC_HAL_GetCrc16 ( CRC_Type *const  base,
uint16_t  data,
bool  newSeed,
uint32_t  seed 
)

Appends 16-bit data to the current CRC calculation and returns new result.

This function appends 16-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
[in]baseThe CRC peripheral base address
[in]dataInput data for CRC calculation
[in]newSeedSets new CRC calculation
  • true: New seed set and used for new calculation.
  • false: Seed argument ignored, continues old calculation.
[in]seedNew seed if newSeed is true, else ignored
Returns
New CRC result

Definition at line 106 of file crc_hal.c.

uint32_t CRC_HAL_GetCrc32 ( CRC_Type *const  base,
uint32_t  data,
bool  newSeed,
uint32_t  seed 
)

Appends 32-bit data to the current CRC calculation and returns new result.

This function 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
[in]baseThe CRC peripheral base address
[in]dataInput data for CRC calculation
[in]newSeedSets new CRC calculation
  • true: New seed set and used for new calculation.
  • false: Seed argument ignored, continues old calculation.
[in]seedNew seed if newSeed is true, else ignored
Returns
New CRC result

Definition at line 80 of file crc_hal.c.

uint32_t CRC_HAL_GetCrc8 ( CRC_Type *const  base,
uint8_t  data,
bool  newSeed,
uint32_t  seed 
)

Appends 8-bit data to the current CRC calculation and returns new result.

This function appends 8-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
[in]baseThe CRC peripheral base address
[in]dataInput data for CRC calculation
[in]newSeedSets new CRC calculation
  • true: New seed set and used for new calculation.
  • false: Seed argument ignored, continues old calculation.
[in]seedNew seed if newSeed is true, else ignored
Returns
New CRC result

Definition at line 132 of file crc_hal.c.

uint32_t CRC_HAL_GetCrcResult ( const CRC_Type *const  base)

Returns the current result of the CRC calculation.

This function returns the current result of the CRC calculation

Parameters
[in]baseThe CRC peripheral base address
Returns
Result of CRC calculation

Definition at line 156 of file crc_hal.c.

static uint16_t CRC_HAL_GetDataHReg ( const CRC_Type *const  base)
inlinestatic

Gets the upper 16 bits of the current CRC result.

This function gets the upper 16 bits of the current CRC result from the data register

Parameters
[in]baseThe CRC peripheral base address
Returns
Returns the upper 16 bits of the current CRC result Implements : CRC_HAL_GetDataHReg_Activity

Definition at line 195 of file crc_hal.h.

static uint16_t CRC_HAL_GetDataLReg ( const CRC_Type *const  base)
inlinestatic

Gets the lower 16 bits of the current CRC result.

This function gets the lower 16 bits of the current CRC result from the data register

Parameters
[in]baseThe CRC peripheral base address
Returns
Returns the lower 16 bits of the current CRC result Implements : CRC_HAL_GetDataLReg_Activity

Definition at line 224 of file crc_hal.h.

static uint32_t CRC_HAL_GetDataReg ( const CRC_Type *const  base)
inlinestatic

Gets the current CRC result.

This function gets the current CRC result from the data register

Parameters
[in]baseThe CRC peripheral base address
Returns
Returns the current CRC result Implements : CRC_HAL_GetDataReg_Activity

Definition at line 166 of file crc_hal.h.

static bool CRC_HAL_GetFXorMode ( const CRC_Type *const  base)
inlinestatic

Gets complement read of CRC data register.

This function gets complement read of CRC data register. Some CRC protocols require the final checksum to be XORed with 0xFFFFFFFF or 0xFFFF. Complement mode enables "on the fly" complementing of read data

Parameters
[in]baseThe CRC peripheral base address
Returns
Complement read -true: Invert or complement the read value of the CRC Data register. -false: No XOR on reading. Implements : CRC_HAL_GetFXorMode_Activity

Definition at line 451 of file crc_hal.h.

static uint16_t CRC_HAL_GetPolyHReg ( const CRC_Type *const  base)
inlinestatic

Gets the upper 16 bits of polynomial register.

This function gets the upper 16 bits of polynomial register. Note that this upper part of the register is not used in 16-bit CRC mode

Parameters
[in]baseThe CRC peripheral base address
Returns
Returns the upper 16 bits of polynomial register Implements : CRC_HAL_GetPolyHReg_Activity

Definition at line 343 of file crc_hal.h.

static uint16_t CRC_HAL_GetPolyLReg ( const CRC_Type *const  base)
inlinestatic

Gets the lower 16 bits of polynomial register.

This function gets the lower 16 bits of polynomial register

Parameters
[in]baseThe CRC peripheral base address
Returns
Returns the lower 16 bits of polynomial register Implements : CRC_HAL_GetPolyLReg_Activity

Definition at line 377 of file crc_hal.h.

static uint32_t CRC_HAL_GetPolyReg ( const CRC_Type *const  base)
inlinestatic

Gets the polynomial register value.

This function gets the polynomial register value

Parameters
[in]baseThe CRC peripheral base address
Returns
Returns the polynomial register value Implements : CRC_HAL_GetPolyReg_Activity

Definition at line 313 of file crc_hal.h.

static crc_bit_width_t CRC_HAL_GetProtocolWidth ( const CRC_Type *const  base)
inlinestatic

Gets the CRC protocol width.

This function gets the CRC protocol width

Parameters
[in]baseThe CRC peripheral base address
Returns
CRC protocol width
  • CRC_BITS_16: 16-bit CRC protocol.
  • CRC_BITS_32: 32-bit CRC protocol. Implements : CRC_HAL_GetProtocolWidth_Activity

Definition at line 488 of file crc_hal.h.

static crc_transpose_t CRC_HAL_GetReadTranspose ( const CRC_Type *const  base)
inlinestatic

Gets the CRC transpose type for reads.

This function gets the CRC transpose type for reads

Parameters
[in]baseThe CRC peripheral base address
Returns
CRC output transpose type Implements : CRC_HAL_GetReadTranspose_Activity

Definition at line 582 of file crc_hal.h.

static bool CRC_HAL_GetSeedOrDataMode ( const CRC_Type *const  base)
inlinestatic

Gets the CRC_DATA register mode.

This function gets the CRC_DATA register mode

Parameters
[in]baseThe CRC peripheral base address
Returns
CRC_DATA register mode -true: CRC_DATA register is used for seed values. -false: CRC_DATA register is used for data values. Implements : CRC_HAL_GetSeedOrDataMode_Activity

Definition at line 412 of file crc_hal.h.

static crc_transpose_t CRC_HAL_GetWriteTranspose ( const CRC_Type *const  base)
inlinestatic

Gets the CRC transpose type for writes.

This function gets the CRC transpose type for writes

Parameters
[in]baseThe CRC peripheral base address
Returns
CRC input transpose type for writes Implements : CRC_HAL_GetWriteTranspose_Activity

Definition at line 530 of file crc_hal.h.

void CRC_HAL_Init ( CRC_Type *const  base)

Initializes the CRC module.

This function initializes the module to default configuration (Initial checksum: 0U, Default polynomial: 0x1021U, Type of read transpose: CRC_TRANSPOSE_NONE, Type of write transpose: CRC_TRANSPOSE_NONE, No complement of checksum read, 32-bit CRC)

Parameters
[in]baseThe CRC peripheral base address

Definition at line 52 of file crc_hal.c.

static void CRC_HAL_SetDataHLReg ( CRC_Type *const  base,
uint8_t  value 
)
inlinestatic

Sets the High Lower Byte - HL.

This function sets the High Lower Byte - HL of CRC data register

Parameters
[in]baseThe CRC peripheral base address
[in]valueNew data for CRC computation Implements : CRC_HAL_SetDataHLReg_Activity

Definition at line 268 of file crc_hal.h.

static void CRC_HAL_SetDataHReg ( CRC_Type *const  base,
uint16_t  value 
)
inlinestatic

Sets the upper 16 bits of CRC data register.

This function sets the upper 16 bits of CRC data register

Parameters
[in]baseThe CRC peripheral base address
[in]valueNew data for CRC computation Implements : CRC_HAL_SetDataHReg_Activity

Definition at line 209 of file crc_hal.h.

static void CRC_HAL_SetDataHUReg ( CRC_Type *const  base,
uint8_t  value 
)
inlinestatic

Sets the High Upper Byte - HU.

This function sets the High Upper Byte - HU of CRC data register

Parameters
[in]baseThe CRC peripheral base address
[in]valueNew data for CRC computation Implements : CRC_HAL_SetDataHUReg_Activity

Definition at line 253 of file crc_hal.h.

static void CRC_HAL_SetDataLLReg ( CRC_Type *const  base,
uint8_t  value 
)
inlinestatic

Sets the Low Lower Byte - LL.

This function sets the Low Lower Byte - LL of CRC data register

Parameters
[in]baseThe CRC peripheral base address
[in]valueNew data for CRC computation Implements : CRC_HAL_SetDataLLReg_Activity

Definition at line 298 of file crc_hal.h.

static void CRC_HAL_SetDataLReg ( CRC_Type *const  base,
uint16_t  value 
)
inlinestatic

Sets the lower 16 bits of CRC data register.

This function sets the lower 16 bits of CRC data register

Parameters
[in]baseThe CRC peripheral base address
[in]valueNew data for CRC computation Implements : CRC_HAL_SetDataLReg_Activity

Definition at line 238 of file crc_hal.h.

static void CRC_HAL_SetDataLUReg ( CRC_Type *const  base,
uint8_t  value 
)
inlinestatic

Sets the Low Upper Byte - LU.

This function sets the Low Upper Byte - LU of CRC data register

Parameters
[in]baseThe CRC peripheral base address
[in]valueNew data for CRC computation Implements : CRC_HAL_SetDataLUReg_Activity

Definition at line 283 of file crc_hal.h.

static void CRC_HAL_SetDataReg ( CRC_Type *const  base,
uint32_t  value 
)
inlinestatic

Sets the 32 bits of CRC data register.

This function sets the 32 bits of CRC data register

Parameters
[in]baseThe CRC peripheral base address
[in]valueNew data for CRC computation Implements : CRC_HAL_SetDataReg_Activity

Definition at line 180 of file crc_hal.h.

static void CRC_HAL_SetFXorMode ( CRC_Type *const  base,
bool  enable 
)
inlinestatic

Sets complement read of CRC data register.

This function sets complement read of CRC data register. Some CRC protocols require the final checksum to be XORed with 0xFFFFFFFF or 0xFFFF. Complement mode enables "on the fly" complementing of read data

Parameters
[in]baseThe CRC peripheral base address
[in]enableEnable or disable complementing of read data Implements : CRC_HAL_SetFXorMode_Activity

Definition at line 467 of file crc_hal.h.

static void CRC_HAL_SetPolyHReg ( CRC_Type *const  base,
uint16_t  value 
)
inlinestatic

Sets the upper 16 bits of polynomial register.

This function sets the upper 16 bits of polynomial register. Note that this upper part of the register is ignored in 16-bit CRC mode

Parameters
[in]baseThe CRC peripheral base address
[in]valuePolynomial value Implements : CRC_HAL_SetPolyHReg_Activity

Definition at line 358 of file crc_hal.h.

static void CRC_HAL_SetPolyLReg ( CRC_Type *const  base,
uint16_t  value 
)
inlinestatic

Sets the lower 16 bits of polynomial register.

This function sets the lower 16 bits of polynomial register

Parameters
[in]baseThe CRC peripheral base address
[in]valuePolynomial value Implements : CRC_HAL_SetPolyLReg_Activity

Definition at line 391 of file crc_hal.h.

static void CRC_HAL_SetPolyReg ( CRC_Type *const  base,
uint32_t  value 
)
inlinestatic

Sets the polynomial register.

This function sets the polynomial register

Parameters
[in]baseThe CRC peripheral base address
[in]valuePolynomial value Implements : CRC_HAL_SetPolyReg_Activity

Definition at line 327 of file crc_hal.h.

static void CRC_HAL_SetProtocolWidth ( CRC_Type *const  base,
crc_bit_width_t  width 
)
inlinestatic

Sets the CRC protocol width.

This function sets the CRC protocol width

Parameters
[in]baseThe CRC peripheral base address
[in]widthThe CRC protocol width
  • CRC_BITS_16: 16-bit CRC protocol.
  • CRC_BITS_32: 32-bit CRC protocol. Implements : CRC_HAL_SetProtocolWidth_Activity

Definition at line 511 of file crc_hal.h.

static void CRC_HAL_SetReadTranspose ( CRC_Type *const  base,
crc_transpose_t  transp 
)
inlinestatic

Sets the CRC transpose type for reads.

This function sets the CRC transpose type for reads

Parameters
[in]baseThe CRC peripheral base address
[in]transpThe CRC output transpose type Implements : CRC_HAL_SetReadTranspose_Activity

Definition at line 615 of file crc_hal.h.

static void CRC_HAL_SetSeedOrDataMode ( CRC_Type *const  base,
bool  enable 
)
inlinestatic

Sets the CRC_DATA register mode.

This function sets the CRC_DATA register mode

Parameters
[in]baseThe CRC peripheral base address
[in]enableEnable CRC data register to use for seed value -true: use CRC data register for seed values. -false: use CRC data register for data values. Implements : CRC_HAL_SetSeedOrDataMode_Activity

Definition at line 428 of file crc_hal.h.

static void CRC_HAL_SetWriteTranspose ( CRC_Type *const  base,
crc_transpose_t  transp 
)
inlinestatic

Sets the CRC transpose type for writes.

This function sets the CRC transpose type for writes

Parameters
[in]baseThe CRC peripheral base address
[in]transpThe CRC input transpose type Implements : CRC_HAL_SetWriteTranspose_Activity

Definition at line 563 of file crc_hal.h.