Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
CRC driver APIs

Interfaces for Cyclic Redundancy Check (CRC) devices. More...

Files

file  crc.h
 CRC public API header file.

Data Structures

struct  crc_ctx
 CRC context structure. More...
struct  crc_driver_api

Typedefs

typedef uint32_t crc_init_val_t
 Provides a type to hold CRC initial seed value.
typedef uint32_t crc_poly_t
 Provides a type to hold CRC polynomial value.
typedef uint32_t crc_result_t
 Provides a type to hold CRC result value.
typedef int(* crc_api_begin) (const struct device *dev, struct crc_ctx *ctx)
 Callback API upon CRC calculation begin See crc_begin() for argument description.
typedef int(* crc_api_update) (const struct device *dev, struct crc_ctx *ctx, const void *buffer, size_t bufsize)
 Callback API upon CRC calculation stream update See crc_update() for argument description.
typedef int(* crc_api_finish) (const struct device *dev, struct crc_ctx *ctx)
 Callback API upon CRC calculation finish See crc_finish() for argument description.

Enumerations

enum  crc_state { CRC_STATE_IDLE = 0 , CRC_STATE_IN_PROGRESS }
 CRC state enumeration. More...

Functions

int crc_begin (const struct device *dev, struct crc_ctx *ctx)
 Configure CRC unit for calculation.
int crc_update (const struct device *dev, struct crc_ctx *ctx, const void *buffer, size_t bufsize)
 Perform CRC calculation on the provided data buffer and retrieve result.
int crc_finish (const struct device *dev, struct crc_ctx *ctx)
 Finalize CRC calculation.
static int crc_verify (struct crc_ctx *ctx, crc_result_t expected)
 Verify CRC result.

CRC input/output string flags

#define CRC_FLAG_REVERSE_INPUT   BIT(0)
 Reverse input string.
#define CRC_FLAG_REVERSE_OUTPUT   BIT(1)
 Reverse output string.

Detailed Description

Interfaces for Cyclic Redundancy Check (CRC) devices.

Macro Definition Documentation

◆ CRC_FLAG_REVERSE_INPUT

#define CRC_FLAG_REVERSE_INPUT   BIT(0)

#include <zephyr/drivers/crc.h>

Reverse input string.

◆ CRC_FLAG_REVERSE_OUTPUT

#define CRC_FLAG_REVERSE_OUTPUT   BIT(1)

#include <zephyr/drivers/crc.h>

Reverse output string.

Typedef Documentation

◆ crc_api_begin

typedef int(* crc_api_begin) (const struct device *dev, struct crc_ctx *ctx)

#include <zephyr/drivers/crc.h>

Callback API upon CRC calculation begin See crc_begin() for argument description.

◆ crc_api_finish

typedef int(* crc_api_finish) (const struct device *dev, struct crc_ctx *ctx)

#include <zephyr/drivers/crc.h>

Callback API upon CRC calculation finish See crc_finish() for argument description.

◆ crc_api_update

typedef int(* crc_api_update) (const struct device *dev, struct crc_ctx *ctx, const void *buffer, size_t bufsize)

#include <zephyr/drivers/crc.h>

Callback API upon CRC calculation stream update See crc_update() for argument description.

◆ crc_init_val_t

#include <zephyr/drivers/crc.h>

Provides a type to hold CRC initial seed value.

◆ crc_poly_t

#include <zephyr/drivers/crc.h>

Provides a type to hold CRC polynomial value.

See CRC_POLYNOMIAL for predefined polynomial values.

◆ crc_result_t

#include <zephyr/drivers/crc.h>

Provides a type to hold CRC result value.

Enumeration Type Documentation

◆ crc_state

enum crc_state

#include <zephyr/drivers/crc.h>

CRC state enumeration.

Enumerator
CRC_STATE_IDLE 

CRC device is in IDLE state.

CRC_STATE_IN_PROGRESS 

CRC calculation is in-progress.

Function Documentation

◆ crc_begin()

int crc_begin ( const struct device * dev,
struct crc_ctx * ctx )

#include <zephyr/drivers/crc.h>

Configure CRC unit for calculation.

Parameters
devPointer to the device structure
ctxPointer to the CRC context structure
Return values
0if successful
-ENOSYSif function is not implemented
errnocode on failure

◆ crc_finish()

int crc_finish ( const struct device * dev,
struct crc_ctx * ctx )

#include <zephyr/drivers/crc.h>

Finalize CRC calculation.

Parameters
devPointer to the device structure
ctxPointer to the CRC context structure
Return values
0if successful
-ENOSYSif function is not implemented
errnocode on failure

◆ crc_update()

int crc_update ( const struct device * dev,
struct crc_ctx * ctx,
const void * buffer,
size_t bufsize )

#include <zephyr/drivers/crc.h>

Perform CRC calculation on the provided data buffer and retrieve result.

Parameters
devPointer to the device structure
ctxPointer to the CRC context structure
bufferPointer to input data buffer
bufsizeNumber of bytes in *buffer
Return values
0if successful
-ENOSYSif function is not implemented
errnocode on failure

◆ crc_verify()

int crc_verify ( struct crc_ctx * ctx,
crc_result_t expected )
inlinestatic

#include <zephyr/drivers/crc.h>

Verify CRC result.

Parameters
ctxPointer to the CRC context structure
expectedExpected CRC result
Return values
0if successful
-EBUSYif CRC calculation is not completed
-EPERMif CRC verification failed