Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions
MbedCRC< polynomial, width > Class Template Reference

Public Member Functions

 MbedCRC (uint32_t initial_xor, uint32_t final_xor, bool reflect_data, bool reflect_remainder)
 Lifetime of CRC object. More...
 
int32_t compute (void *buffer, crc_data_size_t size, uint32_t *crc)
 Compute CRC for the data input Compute CRC performs the initialization, computation and collection of final CRC. More...
 
int32_t compute_partial (void *buffer, crc_data_size_t size, uint32_t *crc)
 Compute partial CRC for the data input. More...
 
int32_t compute_partial_start (uint32_t *crc)
 Compute partial start, indicate start of partial computation. More...
 
int32_t compute_partial_stop (uint32_t *crc)
 Get the final CRC value of partial computation. More...
 
uint32_t get_polynomial (void) const
 Get the current CRC polynomial. More...
 
uint8_t get_width (void) const
 Get the current CRC width. More...
 

Detailed Description

template<uint32_t polynomial = POLY_32BIT_ANSI, uint8_t width = 32>
class mbed::MbedCRC< polynomial, width >

Definition at line 100 of file MbedCRC.h.

Constructor & Destructor Documentation

MbedCRC ( uint32_t  initial_xor,
uint32_t  final_xor,
bool  reflect_data,
bool  reflect_remainder 
)

Lifetime of CRC object.

Parameters
initial_xorInital value/seed to Xor
final_xorFinal Xor value
reflect_data
reflect_remainder
Note
Default constructor without any arguments is valid only for supported CRC polynomials. :: crc_polynomial_t MbedCRC <POLY_7BIT_SD, 7> ct; — Valid POLY_7BIT_SD MbedCRC <0x1021, 16> ct; — Valid POLY_16BIT_CCITT MbedCRC <POLY_16BIT_CCITT, 32> ct; — Invalid, compilation error MbedCRC <POLY_16BIT_CCITT, 32> ct (i,f,rd,rr) Constructor can be used for not supported polynomials MbedCRC<POLY_16BIT_CCITT, 16> sd(0, 0, false, false); Constructor can also be used for supported polynomials with different intial/final/reflect values

Definition at line 128 of file MbedCRC.h.

Member Function Documentation

int32_t compute ( void *  buffer,
crc_data_size_t  size,
uint32_t *  crc 
)

Compute CRC for the data input Compute CRC performs the initialization, computation and collection of final CRC.

Parameters
bufferData bytes
sizeSize of data
crcCRC is the output value
Returns
0 on success, negative error code on failure

Definition at line 149 of file MbedCRC.h.

int32_t compute_partial ( void *  buffer,
crc_data_size_t  size,
uint32_t *  crc 
)

Compute partial CRC for the data input.

CRC data if not available fully, CRC can be computed in parts with available data.

In case of hardware, intermediate values and states are saved by hardware. Mutex locking is used to serialize access to hardware CRC.

In case of software CRC, previous CRC output should be passed as argument to the current compute_partial call. Please note the intermediate CRC value is maintained by application and not the driver.

Precondition
: Call compute_partial_start to start the partial CRC calculation.
Postcondition
: Call compute_partial_stop to get the final CRC value.
Parameters
bufferData bytes
sizeSize of data
crcCRC value is intermediate CRC value filled by API.
Returns
0 on success or a negative error code on failure
Note
: CRC as output in compute_partial is not final CRC value, call compute_partial_stop to get final correct CRC value.

Definition at line 196 of file MbedCRC.h.

int32_t compute_partial_start ( uint32_t *  crc)

Compute partial start, indicate start of partial computation.

This API should be called before performing any partial computation with compute_partial API.

Parameters
crcInitial CRC value set by the API
Returns
0 on success or a negative in case of failure
Note
: CRC is an out parameter and must be reused with compute_partial and compute_partial_stop without any modifications in application.

Definition at line 231 of file MbedCRC.h.

int32_t compute_partial_stop ( uint32_t *  crc)

Get the final CRC value of partial computation.

CRC value available in partial computation is not correct CRC, as some algorithms require remainder to be reflected and final value to be XORed This API is used to perform final computation to get correct CRC value.

Parameters
crcCRC result
Returns
0 on success or a negative in case of failure.

Definition at line 263 of file MbedCRC.h.

uint32_t get_polynomial ( void  ) const

Get the current CRC polynomial.

Returns
Polynomial value

Definition at line 292 of file MbedCRC.h.

uint8_t get_width ( void  ) const

Get the current CRC width.

Returns
CRC width

Definition at line 301 of file MbedCRC.h.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.