这是最新(主)开发分支的文档。如果您正在查找以前版本的文档,使用左侧的下拉菜单选择所需的版本。

CRC API 参考

CRC

typedef wm_hal_crc_cfg_t wm_drv_crc_cfg_t
wm_device_t *wm_drv_crc_init(const char *dev_name)

Initialize CRC driver.

备注

This API must be called before all other CRC API can be called

参数:

dev_name – CRC device name

返回:

  • NULL: failed

  • others: CRC driver device

int wm_drv_crc_deinit(wm_device_t *dev)

Deinitialize CRC driver.

参数:

dev – CRC driver device

返回:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • others: failed

int wm_drv_crc_cfg(wm_device_t *dev, wm_drv_crc_cfg_t *ctx, uint32_t state, uint8_t type, uint8_t reverse)

Fill the wm_drv_crc_cfg_t structure pointed to by ctx with necessary data.

备注

The parameter ctx must be a structure which is allocated externally. And all of Context parameters in the initializing methods should be allocated externally too.

参数:
  • dev[in] Pointer to the CRC device structure.

  • ctx[in] Pointer to the CRC Context.

  • state[in] The initial value input and result value output.

  • type[in] The type of CRC, reference the wm_gpsec_crc_type_t enum.

  • reverse[in] The reverse configuration of CRC, bit0 means output reverse and bit1 means input reverse.

返回:

  • WM_ERR_SUCCESS: succeed

  • others: failed

int wm_drv_crc_update(wm_device_t *dev, wm_drv_crc_cfg_t *ctx, unsigned char *in, uint32_t len)

This function updates the CRC value with a variable length bytes. This function may be called as many times as necessary, so the message may be processed in blocks.

参数:
  • dev[in] Pointer to the CRC device structure.

  • ctx[in] Pointer to the CRC Context.

  • in[in] Pointer to the input data buffer

  • len[in] input data length in bytes

返回:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

  • Other error codes based on the update process

int wm_drv_crc_final(wm_device_t *dev, wm_drv_crc_cfg_t *ctx, uint32_t *crc_val)

output CRC result.

参数:
  • dev[in] Pointer to the CRC device structure.

  • ctx[in] Pointer to the CRC Context.

  • crc_val[out] final result

返回:

  • WM_ERR_SUCCESS: succeed

  • WM_ERR_INVALID_PARAM: invalid argument

uint32_t wm_drv_crc32_reverse(const void *buf, unsigned int len)

Generic function for computing a CRC-32 with input and output reflection.

备注

initial seed: 0xFFFFFFFF

参数:
  • buf – Input bytes for the computation

  • len – Length of the input in bytes

返回:

The computed CRC32 value