Cyclic Redundancy Check Library

This Library provides a set of functions for using the MSPWare CRC32 module. Functions are provided to initialize the CRC and create a CRC signature to check the validity of data.
This is mostly useful in the communication of data, or as a startup procedure to as a more complex and accurate check of data.

The CRC32 module offers no interrupts and is used only to generate CRC signatures to verify against pre-made CRC signatures (Checksums). The CRC32 module provides the capability for both 32-bit and 16-bit calculations.
As such, the DriverLib API provides functionality for the user to provide variable bit-length data for either 16-bit or 32-bit calculations.

Library Routines

CRC32_setSeed

Prototype

void CRC32_setSeed(uint32_t seed, uint_fast8_t crcType);

Description

This function sets the seed for the CRC to begin generating a signature with the given seed and all passed data. Using this function resets the CRC32 signature.

Parameters
  • seed: seed for the CRC to start generating a signature from. Modified bits are CRC16INIRESL0 of CRC16INIRESL0 register, or CRC32INIRESL0 of CRC32INIRESL0 register, depending on the mode set.
  • crcType: CRC mode. Valid values :
    Value Description
    CRC16_MODE 16-bit mode.
    CRC32_MODE 32-bit mode.
Returns

Nothing.

Requires

Nothing.

Notes

Available only for MSP432 devices.

CRC32_set8BitData

Prototype

void CRC32_set8BitData(uint8_t dataIn, uint_fast8_t crcType);

Description

This function sets the 8 Bit data to add into the CRC module to generate a new signature.
This function sets the given data into the CRC module to generate the new signature from the current signature and new data. Bit 0 is treated as LSB.

Parameters
  • dataIn: data to be added, through the CRC module, to the signature. Modified bits are CRC16DIB0 of CRC16DIB0 register, or CRC32DIB0 of CRC32DIB0 register, depending on the mode set.
  • crcType: CRC mode. Valid values :
    Value Description
    CRC16_MODE 16-bit mode.
    CRC32_MODE 32-bit mode.
Returns

Nothing.

Requires

Nothing.

Notes

Available only for MSP432 devices.

CRC32_set16BitData

Prototype

void CRC32_set16BitData(uint16_t dataIn, uint_fast8_t crcType);

Description

This function sets the 16 Bit data to add into the CRC module to generate a new signature.
This function sets the given data into the CRC module to generate the new signature from the current signature and new data. Bit 0 is treated as LSB.

Parameters
  • dataIn: data to be added, through the CRC module, to the signature. Modified bits are CRC16DIW0 of CRC16DIW0 register, or CRC32DIW0 of CRC32DIW0 register, depending on the mode set.
  • crcType: CRC mode. Valid values :
    Value Description
    CRC16_MODE 16-bit mode.
    CRC32_MODE 32-bit mode.
Returns

Nothing.

Requires

Nothing.

Notes

Available only for MSP432 devices.

CRC32_set32BitData

Prototype

void CRC32_set32BitData(uint32_t dataIn);

Description

This function sets the 32 Bit data to add into the CRC module to generate a new signature.
This function sets the given data into the CRC module to generate the new signature from the current signature and new data. Bit 0 is treated as LSB.

Parameters
  • dataIn: data to be added, through the CRC module, to the signature. Modified bits are CRC32DIL0 of CRC32DIL0 register.
Returns

Nothing.

Requires

Nothing.

Notes

Available only for MSP432 devices.

CRC32_set8BitDataReversed

Prototype

void CRC32_set8BitDataReversed(int8_t dataIn, uint_fast8_t crcType);

Description

Translates the data by reversing the bits in each 8 bit data and then sets this data to add into the CRC module to generate a new signature.
This function first reverses the bits in each byte of the data and then generates the new signature from the current signature and new translated data. Bit 0 is treated as MSB.

Parameters
  • dataIn: data to be added, through the CRC module, to the signature. Modified bits are CRC16DIRBB0 of CRC16DIRBB0 register or CRC32DIRBB0 of CRC32DIRBB0 register, depending on the type set.
  • crcType: CRC mode. Valid values :
    Value Description
    CRC16_MODE 16-bit mode.
    CRC32_MODE 32-bit mode.
Returns

Nothing.

Requires

Nothing.

Notes

Available only for MSP432 devices.

CRC32_set16BitDataReversed

Prototype

void CRC32_set16BitDataReversed(int16_t dataIn, uint_fast8_t crcType);

Description

Translates the data by reversing the bits in each 16 bit data and then sets this data to add into the CRC module to generate a new signature.
This function first reverses the bits in each byte of the data and then generates the new signature from the current signature and new translated data. Bit 0 is treated as MSB.

Parameters
  • dataIn: data to be added, through the CRC module, to the signature. Modified bits are CRC16DIRBW0 of CRC16DIRBW0 register or CRC32DIRBW0 of CRC32DIRBW0 register, depending on the type set.
  • crcType: CRC mode. Valid values :
    Value Description
    CRC16_MODE 16-bit mode.
    CRC32_MODE 32-bit mode.
Returns

Nothing.

Requires

Nothing.

Notes

Available only for MSP432 devices.

CRC32_set32BitDataReversed

Prototype

void CRC32_set32BitDataReversed(uint32_t dataIn);

Description

Translates the data by reversing the bits in each 32 bit data and then sets this data to add into the CRC module to generate a new signature.
This function first reverses the bits in each byte of the data and then generates the new signature from the current signature and new translated data. Bit 0 is treated as MSB.

Parameters
  • dataIn: data to be added, through the CRC module, to the signature. Modified bits are CRC16DIRBW0 of CRC16DIRBW0 register or CRC32DIRBW0 of CRC32DIRBW0 register, depending on the type set.
  • crcType: CRC mode. Valid values :
    Value Description
    CRC16_MODE 16-bit mode.
    CRC32_MODE 32-bit mode.
Returns

Nothing.

Requires

Nothing.

Notes

Available only for MSP432 devices.

CRC32_getResult

Prototype

uint32_t CRC32_getResult(uint_fast8_t crcType);

Description

This function returns the value of the signature result generated by the CRC. Bit 0 is treated as LSB.

Parameters
  • crcType: CRC mode. Valid values :
    Value Description
    CRC16_MODE 16-bit mode.
    CRC32_MODE 32-bit mode.
Returns

Returns the value of CRC Signature Result.

Requires

Nothing.

Notes

Available only for MSP432 devices.

CRC32_getResultReversed

Prototype

uint32_t CRC32_getResultReversed(uint_fast8_t crcType);

Description

This function returns the bit-wise reversed format of the Signature Result. Bit 0 is treated as MSB.

Parameters
  • crcType: CRC mode. Valid values :
    Value Description
    CRC16_MODE 16-bit mode.
    CRC32_MODE 32-bit mode.
Returns

Returns the bit-wise reversed format of the 32 bit Signature Result..

Requires

Nothing.

Notes

Available only for MSP432 devices.

Copyright (c) 2002-2019 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code