RZT Flexible Software Package Documentation  Release v2.2.0

 
Cyclic Redundancy Check (CRC) Calculator (r_crc)

Functions

fsp_err_t R_CRC_Open (crc_ctrl_t *const p_ctrl, crc_cfg_t const *const p_cfg)
 
fsp_err_t R_CRC_Close (crc_ctrl_t *const p_ctrl)
 
fsp_err_t R_CRC_Calculate (crc_ctrl_t *const p_ctrl, crc_input_t *const p_crc_input, uint32_t *calculatedValue)
 
fsp_err_t R_CRC_CalculatedValueGet (crc_ctrl_t *const p_ctrl, uint32_t *calculatedValue)
 
fsp_err_t R_CRC_SnoopEnable (crc_ctrl_t *const p_ctrl, uint32_t crc_seed)
 
fsp_err_t R_CRC_SnoopDisable (crc_ctrl_t *const p_ctrl)
 

Detailed Description

Driver for the CRC peripheral on RZ microprocessor. This module implements the CRC Interface.

Overview

The CRC module provides a API to calculate 8, 16 and 32-bit CRC values on a block of data in memory using industry-standard polynomials.

Features

Configuration

Build Time Configurations for r_crc

The following build time configurations are defined in fsp_cfg/r_crc_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.

Configurations for Monitoring > CRC (r_crc)

This module can be added to the Stacks tab via New Stack > Monitoring > CRC (r_crc).

ConfigurationOptionsDefaultDescription
NameName must be a valid C symbolg_crc0 Module name.
ChannelValue must be 0 or 10 Select the CRC channel.
CRC Polynomial
  • CRC-8
  • CRC-16
  • CRC-CCITT
  • CRC-32
  • CRC-32C
CRC-32C Select the CRC polynomial.
Bit Order
  • LSB
  • MSB
MSB Select the CRC bit order.

Clock Configuration

There is no clock configuration for the CRC module.

Pin Configuration

This module does not use I/O pins.

Usage Notes

Limitations

When using CRC32 polynomial functions the CRC module produces the same results as popular online CRC32 calculators, but it is important to remember a few important points.

Examples

Basic Example

This is a basic example of minimal use of the CRC module in an application.

void crc_example ()
{
uint32_t length;
uint32_t uint8_calculated_value;
length = sizeof(g_data_8bit) / sizeof(g_data_8bit[0]);
crc_input_t example_input =
{
.p_input_buffer = g_data_8bit,
.num_bytes = length,
.crc_seed = 0,
};
/* Open CRC module with 8 bit polynomial */
R_CRC_Open(&crc_ctrl, &g_crc_test_cfg);
/* 8-bit CRC calculation */
R_CRC_Calculate(&crc_ctrl, &example_input, &uint8_calculated_value);
}

Data Structures

struct  crc_instance_ctrl_t
 

Data Structure Documentation

◆ crc_instance_ctrl_t

struct crc_instance_ctrl_t

Driver instance control structure.

Function Documentation

◆ R_CRC_Open()

fsp_err_t R_CRC_Open ( crc_ctrl_t *const  p_ctrl,
crc_cfg_t const *const  p_cfg 
)

Open the CRC driver module.

Implements crc_api_t::open

Open the CRC driver module and initialize the driver control block according to the passed-in configuration structure.

Return values
FSP_SUCCESSConfiguration was successful.
FSP_ERR_ASSERTIONp_ctrl or p_cfg is NULL.
FSP_ERR_ALREADY_OPENModule already open.
FSP_ERR_IP_CHANNEL_NOT_PRESENTThe requested channel does not exist on this MCU.

◆ R_CRC_Close()

fsp_err_t R_CRC_Close ( crc_ctrl_t *const  p_ctrl)

Close the CRC module driver.

Implements crc_api_t::close

Return values
FSP_SUCCESSConfiguration was successful.
FSP_ERR_ASSERTIONp_ctrl is NULL.
FSP_ERR_NOT_OPENThe driver is not opened.

◆ R_CRC_Calculate()

fsp_err_t R_CRC_Calculate ( crc_ctrl_t *const  p_ctrl,
crc_input_t *const  p_crc_input,
uint32_t *  calculatedValue 
)

Perform a CRC calculation on a block of 8-bit/32-bit (for 32-bit polynomial) data.

Implements crc_api_t::calculate

This function performs a CRC calculation on an array of 8-bit/32-bit (for 32-bit polynomial) values and returns an 8-bit/32-bit (for 32-bit polynomial) calculated value

Return values
FSP_SUCCESSCalculation successful.
FSP_ERR_ASSERTIONEither p_ctrl, p_crc_input, inputBuffer, or calculatedValue is NULL.
FSP_ERR_INVALID_ARGUMENTlength value is NULL.
FSP_ERR_NOT_OPENThe driver is not opened.

◆ R_CRC_CalculatedValueGet()

fsp_err_t R_CRC_CalculatedValueGet ( crc_ctrl_t *const  p_ctrl,
uint32_t *  calculatedValue 
)

Return the current calculated value.

Implements crc_api_t::crcResultGet

CRC calculation operates on a running value. This function returns the current calculated value.

Return values
FSP_SUCCESSReturn of calculated value successful.
FSP_ERR_ASSERTIONEither p_ctrl or calculatedValue is NULL.
FSP_ERR_NOT_OPENThe driver is not opened.

◆ R_CRC_SnoopEnable()

fsp_err_t R_CRC_SnoopEnable ( crc_ctrl_t *const  p_ctrl,
uint32_t  crc_seed 
)

crc_api_t::snoopEnable is not supported on the CRC.

Return values
FSP_ERR_UNSUPPORTEDFunction not supported in this implementation.

◆ R_CRC_SnoopDisable()

fsp_err_t R_CRC_SnoopDisable ( crc_ctrl_t *const  p_ctrl)

crc_api_t::snoopDisable is not supported on the CRC.

Return values
FSP_ERR_UNSUPPORTEDFunction not supported in this implementation.