RAFW Flexible Software Package Documentation  Release v2.0.1

 
CRC (r_crc_w)

Functions

fsp_err_t R_CRC_W_Open (crc_ctrl_t *const p_ctrl, crc_cfg_t const *const p_cfg)
 
fsp_err_t R_CRC_W_Close (crc_ctrl_t *const p_ctrl)
 
fsp_err_t R_CRC_W_Calculate (crc_ctrl_t *const p_ctrl, crc_input_t *const p_crc_input, uint32_t *p_calculatedValue)
 
fsp_err_t R_CRC_W_CalculatedValueGet (crc_ctrl_t *const p_ctrl, uint32_t *p_calculatedValue)
 
fsp_err_t R_CRC_W_SnoopEnable (crc_ctrl_t *const p_ctrl, uint32_t crc_seed)
 
fsp_err_t R_CRC_W_SnoopDisable (crc_ctrl_t *const p_ctrl)
 

Detailed Description

Driver for the CRC peripheral on RA6W1/RA6W2 MCUs. This module implements the CRC Interface.

Overview

The CRC module provides an API to calculate 16 and 32-bit CRC values on a block of data in memory or a data being transferred by the bus master (DMA) using industry-standard polynomials.

Features

Configuration

Build Time Configurations for r_crc_w

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

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.
DMAC Support
  • Enabled
  • Disabled
Disabled If enabled, DMAC instance will be included in the build.

Configurations for Monitoring > CRC (r_crc_w)

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

ConfigurationOptionsDefaultDescription
NameName must be a valid C symbolg_crc0 Module name.
ChannelValue must be a non-negative integer0 Specifies the CRC calculation channel.
CRC Polynomial
  • CRC-32
  • CRC-32C
  • CRC-16 CCITT
  • CRC-16 IBM
CRC-32 Select the CRC polynomial.
Input Data Swap Enable
  • Normal
  • Byte Swap
Normal Input data swap enable.
Bit Endian Type
  • Big Endian
  • Little Endian
Big Endian Bit endian type.
Parallel Type
  • 8 bits
  • 16 bits
  • 32 bits
8 bits Parallel type of CRC calculation.
Access Type
  • Read access
  • Write access
Read access Access type of CRC calculation.

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_basic_example (void)
{
uint32_t length;
uint32_t calculated_value;
length = sizeof(g_crc_data) / sizeof(g_crc_data[0]);
crc_input_t example_input =
{
.p_input_buffer = g_crc_data,
.num_bytes = length,
.crc_seed = 0,
};
/* Open CRC module */
R_CRC_W_Open(&g_crc_ctrl, &g_crc_cfg);
/* CRC calculation and Read CRC value */
R_CRC_W_Calculate(&g_crc_ctrl, &example_input, &calculated_value);
}

DMA Example

This example demonstrates CRC DMA operation.

void g_dmac_callback (dmac_callback_args_t * cb_data)
{
g_dmac_transfer_complete = true;
}
void crc_dma_example (void)
{
uint32_t length;
uint32_t calculated_value;
length = sizeof(g_crc_data) / sizeof(g_crc_data[0]);
crc_input_t example_input =
{
.p_input_buffer = g_crc_data,
.num_bytes = length,
.crc_seed = 0,
};
g_dmac_transfer_complete = false;
/* Open CRC module */
R_CRC_W_Open(&g_crc_ctrl, &g_crc_cfg);
/* CRC calculation */
R_CRC_W_Calculate(&g_crc_ctrl, &example_input, NULL);
while (!g_dmac_transfer_complete);
/* Read CRC value */
R_CRC_W_CalculatedValueGet(&g_crc_ctrl, &calculated_value);
}

Data Structures

struct  crc_w_instance_ctrl_t
 
struct  crc_w_extended_cfg_t
 

Enumerations

enum  crc_w_channel_t
 
enum  crc_w_polynomial_t
 
enum  crc_w_path_selection_t
 
enum  crc_w_swap_enable_t
 
enum  crc_w_endian_type_t
 
enum  crc_w_parallel_type_t
 
enum  crc_w_access_type_t
 
enum  crc_w_calculation_status_t
 
enum  crc_w_remap_address_0_t
 

Data Structure Documentation

◆ crc_w_instance_ctrl_t

struct crc_w_instance_ctrl_t

Driver instance control structure.

Data Fields
uint32_t open Whether or not driver is open.
const crc_cfg_t * p_cfg Pointer to initial configuration.

◆ crc_w_extended_cfg_t

struct crc_w_extended_cfg_t

Extended configuration.

Data Fields
crc_w_channel_t channel CRC channel.
crc_w_polynomial_t polynomial CRC Generating Polynomial.
crc_w_swap_enable_t swap_enable Input Data Swap Enable.
crc_w_endian_type_t endian_type Bit Endian Type.
crc_w_parallel_type_t parallel_type Parallel Type of CRC Calculation.
crc_w_access_type_t access_type Access Type of CRC Calculation.
crc_w_path_selection_t path_selection Path Selection of CRC Calculation.
transfer_instance_t const * p_transfer DMAC instance. Set to NULL if unused.

Enumeration Type Documentation

◆ crc_w_channel_t

CRC channel.

Enumerator
CRC_W_CHANNEL_0 

CRC channel 0.

CRC_W_CHANNEL_1 

CRC channel 1.

◆ crc_w_polynomial_t

CRC Generating Polynomial.

Enumerator
CRC_W_POLYNOMIAL_CRC_32 

32-bit CRC-32

X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 + X^8 + X^7 + X^5 + X^4 + X^2 + X + 1

CRC_W_POLYNOMIAL_CRC_32C 

32-bit CRC-32C

X^32 + X^28 + X^27 + X^26 + X^25 + X^23 + X^22 + X^20 + X^19 + X^18 + X^14 + X^13 + X^11 + X^10 + X^9 + X^8 + X^6 + 1

CRC_W_POLYNOMIAL_CRC_16_CCITT 

16-bit CRC-16-CCITT

X^16 + X^12 + X^5 + 1

CRC_W_POLYNOMIAL_CRC_16_IBM 

16-bit CRC-16-IBM

X^16 + X^15 + X^2 + 1

◆ crc_w_path_selection_t

Enumerator
CRC_W_PATH_SELECT_CPU 

CPU.

CRC_W_PATH_SELECT_DMA 

DMA.

◆ crc_w_swap_enable_t

Enumerator
CRC_W_SWAP_NORMAL 

Data swap normal.

CRC_W_SWAP_BYTE 

Data swap byte.

◆ crc_w_endian_type_t

Enumerator
CRC_W_ENDIAN_BIG 

Big endian.

CRC_W_ENDIAN_LITTLE 

Little endian.

◆ crc_w_parallel_type_t

Enumerator
CRC_W_PARALLEL_TYPE_8 

8 bit

CRC_W_PARALLEL_TYPE_16 

16 bit

CRC_W_PARALLEL_TYPE_32 

32 bit

◆ crc_w_access_type_t

Enumerator
CRC_W_ACCESS_TYPE_READ 

Read access.

CRC_W_ACCESS_TYPE_WRITE 

Write access.

◆ crc_w_calculation_status_t

Enumerator
CRC_W_CAL_STATUS_IDLE 

CRC calculation status idle.

CRC_W_CAL_STATUS_BUSY 

CRC calculation status busy.

CRC_W_CAL_STATUS_STOP 

CRC calculation status stop.

CRC_W_CAL_STATUS_ERROR 

CRC calculation status error.

◆ crc_w_remap_address_0_t

Remap address 0.

Enumerator
CRC_W_REMAP_ADDRESS_0_TO_ROM 

ROM.

CRC_W_REMAP_ADDRESS_0_TO_OQSPI_FLASH 

OQSPI.

CRC_W_REMAP_ADDRESS_0_TO_RAM 

RAM.

Function Documentation

◆ R_CRC_W_Open()

fsp_err_t R_CRC_W_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_TIMEOUTCRC is busy.
Returns
See Common Error Codes for other possible return codes. This function internally calls transfer_api_t::open.

◆ R_CRC_W_Close()

fsp_err_t R_CRC_W_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. Status of CRC calculation is ERROR.
FSP_ERR_NOT_OPENThe driver is not opened.
FSP_ERR_TIMEOUTCRC is not stopped.

◆ R_CRC_W_Calculate()

fsp_err_t R_CRC_W_Calculate ( crc_ctrl_t *const  p_ctrl,
crc_input_t *const  p_crc_input,
uint32_t *  p_calculatedValue 
)

Perform a CRC calculation on a block of data.

Implements crc_api_t::calculate

If not using DMA, returns the calculated CRC value. If using DMA, use R_CRC_W_CalculatedValueGet to get the calculated value.

Return values
FSP_SUCCESSCalculation successful.
FSP_ERR_ASSERTIONEither p_ctrl, inputBuffer, or p_calculatedValue is NULL. Status of CRC calculation is ERROR.
FSP_ERR_INVALID_ARGUMENTlength value is NULL.
FSP_ERR_NOT_OPENThe driver is not opened.
FSP_ERR_TIMEOUTCRC is not stopped. CRC is busy.

◆ R_CRC_W_CalculatedValueGet()

fsp_err_t R_CRC_W_CalculatedValueGet ( crc_ctrl_t *const  p_ctrl,
uint32_t *  p_calculatedValue 
)

Return the 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 p_calculatedValue is NULL.
FSP_ERR_NOT_OPENThe driver is not opened.
FSP_ERR_TIMEOUTCRC calculation is not stopped.

◆ R_CRC_W_SnoopEnable()

fsp_err_t R_CRC_W_SnoopEnable ( crc_ctrl_t *const  p_ctrl,
uint32_t  crc_seed 
)

Configure the snoop channel and set the CRC seed.

Implements crc_api_t::snoopEnable

The CRC calculator can operate on reads and writes over any of the first ten SCI channels. For example, if set to channel 0, transmit, every byte written out SCI channel 0 is also sent to the CRC calculator as if the value was explicitly written directly to the CRC calculator.

Return values
FSP_ERR_UNSUPPORTEDSNOOP operation is not supported.

◆ R_CRC_W_SnoopDisable()

fsp_err_t R_CRC_W_SnoopDisable ( crc_ctrl_t *const  p_ctrl)

Disable snooping.

Implements crc_api_t::snoopDisable

Return values
FSP_ERR_UNSUPPORTEDSNOOP operation is not supported.