Checksum/CRC Utilities. More...

Modules

Types
Checksum/CRC data types.
 

Functions

gos_result_t gos_crc_init (const gos_crc_config_t *config, gos_crc_context_t *context_ptr)
 Initialize CRC generation hardware. More...
 
gos_result_t gos_crc_deinit (gos_crc_context_t context)
 De-initialize CRC generation hardware. More...
 
gos_result_t gos_crc_reset (gos_crc_context_t context)
 Reset CRC hardware. More...
 
gos_result_t gos_crc_calculate (gos_crc_context_t context, const void *buffer, uint32_t length, uint32_t *crc_ptr)
 Perform CRC calculation. More...
 
gos_result_t gos_crc_get_result (gos_crc_context_t context, uint32_t *crc_ptr, uint32_t timeout_ms)
 Get result of CRC calculation. More...
 
gos_result_t gos_crc_direct_crc32 (const void *buffer, uint32_t length, uint32_t *crc_ptr)
 Perform a direct CRC32 calculation. More...
 

Detailed Description

Checksum/CRC Utilities.

Function Documentation

◆ gos_crc_calculate()

gos_result_t gos_crc_calculate ( gos_crc_context_t  context,
const void *  buffer,
uint32_t  length,
uint32_t *  crc_ptr 
)

Perform CRC calculation.

This performs a CRC calculation on the given buffer with the previously allocated context.

gos_crc_init() must be called first to allocate the context.

If the crc_ptr argument is supplied, then this API blocks until the calculation is complete. The uint32_t buffer crc_ptr points to will be populated with the calculated result.

If the crc_ptr argument is NOT supplied (i.e. is NULL), then this API returns GOS_PENDING immediately and the CRC is calculated in the background using DMA. This allows the application/OS to perform other tasks while the CRC is calculated. Use gos_crc_get_result() to obtain the result of the background CRC calculation.

This API may be called multiple times to calculate a CRC across multiple buffers. If a background CRC is currently active, then this API will block until that background CRC completes.

Use gos_crc_reset() to reset the currently calculated CRC value. This effectively starts the CRC calculation from the beginning.

Note
If a background calculation is executed, then gos_crc_get_result() MUST eventually be called to release the hardware.
Parameters
contextPointer to allocated context
bufferBuffer to calculate CRC on
lengthLength of supplied buffer in bytes
crc_ptrPointer to result, leave NULL to perform background calculation
Returns
gos_result_t result of API call, GOS_PENDING if background calculation is performed

◆ gos_crc_deinit()

gos_result_t gos_crc_deinit ( gos_crc_context_t  context)

De-initialize CRC generation hardware.

Parameters
contextPointer to allocated context
Returns
gos_result_t result of API call

◆ gos_crc_direct_crc32()

gos_result_t gos_crc_direct_crc32 ( const void *  buffer,
uint32_t  length,
uint32_t *  crc_ptr 
)

Perform a direct CRC32 calculation.

This calculates a CRC32 on the given buffer and returns the result in the supplied crc_ptr. This does not require an allocated context.

Note
This is intended for small calculations as it does NOT used DMA. For large calculations it is recommended to use gos_crc_calculate()
Parameters
bufferBuffer to calculate CRC32 on
lengthLength of supplied buffer in bytes
crc_ptrPointer to hold result of calculated CRC32
Returns
gos_result_t result of API call

◆ gos_crc_get_result()

gos_result_t gos_crc_get_result ( gos_crc_context_t  context,
uint32_t *  crc_ptr,
uint32_t  timeout_ms 
)

Get result of CRC calculation.

Get the result of the CRC calculation invoked with gos_crc_calculate()

If gos_crc_calculate() was invoked with a background calculation, then this blocks up to timeout_ms milliseconds for the calculation to complete. If gos_crc_calculate() was NOT invoked with a background calculation, this is immediately returns the result of the last calculation for this given context.

Parameters
contextPointer to allocated context
crc_ptrPointer to hold calculation result
timeout_msTime in milliseconds to wait for background calculation to complete
Returns
gos_result_t result of API call

◆ gos_crc_init()

gos_result_t gos_crc_init ( const gos_crc_config_t config,
gos_crc_context_t context_ptr 
)

Initialize CRC generation hardware.

Use gos_crc_deinit() to release the allocated buffer when it is no longer needed.

Parameters
configgos_crc_config_t Hardware configuration
context_ptrPointer to hold allocate context, this should be used in all other CRC API calls
Returns
gos_result_t result of API call

◆ gos_crc_reset()

gos_result_t gos_crc_reset ( gos_crc_context_t  context)

Reset CRC hardware.

This resets the currently calculated CRC value back to it initialization value specified in gos_crc_init(). This allows for calculating a new CRC with an exiting gos_crc_context_t

gos_crc_init() must be called first to allocate the context.

Parameters
contextPointer to allocated context
Returns
gos_result_t result of API call