14#ifndef ZEPHYR_INCLUDE_DRIVERS_CRC_H
15#define ZEPHYR_INCLUDE_DRIVERS_CRC_H
44#define CRC_FLAG_REVERSE_INPUT BIT(0)
49#define CRC_FLAG_REVERSE_OUTPUT BIT(1)
60#define CRC4_INIT_VAL 0x0
63#define CRC4_TI_INIT_VAL 0x0
66#define CRC7_BE_INIT_VAL 0x0
69#define CRC8_INIT_VAL 0x0
72#define CRC8_CCITT_INIT_VAL 0xFF
75#define CRC8_ROHC_INIT_VAL 0xFF
78#define CRC16_INIT_VAL 0x0
81#define CRC16_ANSI_INIT_VAL 0x0
84#define CRC16_CCITT_INIT_VAL 0x0000
87#define CRC16_ITU_T_INIT_VAL 0x0000
90#define CRC24_PGP_INIT_VALUE 0x00B704CEU
93#define CRC32_C_INIT_VAL 0xFFFFFFFFU
96#define CRC32_IEEE_INIT_VAL 0xFFFFFFFFU
99#define CRC32_K_4_2_INIT_VAL 0xFFFFFFFFU
102#define CRC32_MPEG2_INIT_VAL 0xFFFFFFFFU
210static inline int z_impl_crc_begin(
const struct device *dev,
struct crc_ctx *ctx)
218 return api->
begin(dev, ctx);
236static inline int z_impl_crc_update(
const struct device *dev,
struct crc_ctx *ctx,
237 const void *buffer,
size_t bufsize)
245 return api->
update(dev, ctx, buffer, bufsize);
260static inline int z_impl_crc_finish(
const struct device *dev,
struct crc_ctx *ctx)
268 return api->
finish(dev, ctx);
291 if (expected != ctx->
result) {
306#include <zephyr/syscalls/crc.h>
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1449
uint32_t crc_init_val_t
Provides a type to hold CRC initial seed value.
Definition crc.h:120
uint32_t crc_result_t
Provides a type to hold CRC result value.
Definition crc.h:131
int(* crc_api_update)(const struct device *dev, struct crc_ctx *ctx, const void *buffer, size_t bufsize)
Callback API to feed data into an in-progress CRC calculation.
Definition crc.h:174
int(* crc_api_begin)(const struct device *dev, struct crc_ctx *ctx)
@def_driverbackendgroup{CRC,crc_interface}
Definition crc.h:167
uint32_t crc_poly_t
Provides a type to hold CRC polynomial value.
Definition crc.h:126
int crc_finish(const struct device *dev, struct crc_ctx *ctx)
Finalize CRC calculation.
crc_state
CRC state enumeration.
Definition crc.h:110
int(* crc_api_finish)(const struct device *dev, struct crc_ctx *ctx)
Callback API to finalize CRC calculation.
Definition crc.h:182
int crc_begin(const struct device *dev, struct crc_ctx *ctx)
Configure CRC unit for calculation.
static int crc_verify(struct crc_ctx *ctx, crc_result_t expected)
Verify CRC result.
Definition crc.h:281
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.
@ CRC_STATE_IN_PROGRESS
CRC calculation is in-progress.
Definition crc.h:114
@ CRC_STATE_IDLE
CRC device is in IDLE state.
Definition crc.h:112
crc_type
CRC algorithm enumeration.
Definition crc.h:106
#define EINVAL
Invalid argument.
Definition errno.h:61
#define ENOSYS
Function not implemented.
Definition errno.h:83
#define EBUSY
Mount device busy.
Definition errno.h:55
#define EPERM
Not owner.
Definition errno.h:40
#define NULL
Definition iar_missing_defs.h:20
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
CRC context structure.
Definition crc.h:141
crc_poly_t polynomial
CRC polynomial.
Definition crc.h:149
enum crc_state state
Current CRC device state.
Definition crc.h:145
crc_init_val_t seed
CRC initial seed value.
Definition crc.h:151
uint32_t reversed
CRC input/output reverse flags.
Definition crc.h:147
crc_result_t result
CRC result.
Definition crc.h:153
enum crc_type type
CRC calculation type.
Definition crc.h:143
@driver_ops{CRC}
Definition crc.h:187
crc_api_finish finish
@driver_ops_optional Finalize CRC calculation.
Definition crc.h:193
crc_api_update update
@driver_ops_optional Perform CRC calculation on the provided data buffer and retrieve result.
Definition crc.h:191
crc_api_begin begin
@driver_ops_optional Configure CRC unit for calculation.
Definition crc.h:189
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
CRC computation function.