Renesas CRC HAL Application Note

Application Note Renesas Synergy™ Platform
CRC HAL Module Guide
Introduction
This module guide will enable you to effectively use a module in your own design. Upon completion of this guide, you will be able to add this module to your own design, configure it correctly for the target application and write code, using the included application project code as a reference and an efficient starting point. References to more detailed API descriptions and suggestions of other application projects that illustrate more advanced uses of the module are included in the document and should be valuable resources for creating more complex designs.
The CRC HAL module is a high-level API used to calculate 8, 16 and 32-bit CRC values on a block of data in memory or a stream of data over a Serial Communication Interface (SCI) channel using various types of industry-standard polynomials. The CRC HAL module is implemented on r_crc and uses the CRC peripheral on the Synergy MCU.
Contents
1. CRC HAL Module Features ..................................................................................................... 2
2. CRC APIs Overview ................................................................................................................ 2
3. CRC HAL Module Operational Overview ................................................................................. 3
3.1 CRC HAL Module Important Operat ional Notes and Li mitations ............................................................ 3
3.1.1 CRC HAL Module Operational Notes .................................................................................................... 3
3.2 CRC HAL Module Limitations .................................................................................................................. 3
4. Including the CRC HAL Module in an Application .................................................................... 3
5. Configuring the CRC HAL Module ........................................................................................... 4
5.1 CRC HAL Module Clock Configuration ................................................................................................... 5
5.2 CRC HAL Module Pin Configuration ....................................................................................................... 5
6. Using the CRC HAL Module in an Application ......................................................................... 5
7. The CRC HAL Module Application Project ............................................................................... 6
8. Customizing the CRC HAL Module for a Target Application .................................................... 7
9. Running the CRC HAL Module Application Project .................................................................. 7
10. CRC HAL Module Conclusion .................................................................................................. 8
11. CRC HAL Module Next Steps .................................................................................................. 8
12. CRC HAL Module Reference Information ................................................................................ 8
R11AN0092EU0102 Rev.1.02 Page 1 of 10 Feb.01.19
Renesas Synergy™ Platform CRC HAL Module Guide
Function Name
Example API Call and Description
.open
g_crc.p_api->open(g_crc.p_ctrl, g_crc.p_cfg);
Open the CRC driver module.
.close
g_crc.p_api->close(g_crc.p_ctrl);
.crcResultGet
g_crc.p_api->crcResultGet(g_crc.p_ctrl, &result);
Return the current calculated value.
.snoopEnable
g_crc.p_api->snoopEnable(g_crc.p_ctrl, seed);
.snoopDisable
g_crc.p_api->snoopDisable(g_crc.p_ctrl);
Disable snooping.

1. CRC HAL Module Features

CRC HAL module can calculate CRC on a block of data in memory.
CRC HAL module can calculate CRC on a stream of data being transmitted or received over a serial
communication Interface (SCI) channel (snoop mode).
CRC HAL module supports the following 8-bit and 16-bit CRC polynomials which operates on 8-bit data in parallel
8
CRC HAL module supports the following 32-bit CRC polynomials which operates on 32-bit data in parallel
CRC HAL module can calculate CRC with LSB first or MSB first bit order.
2
+
+ + 1 (CRC-8)
16
+ 15+
16
+ 12+
32
+ 26+ 23+ 22+ 16+ 12+ 11+ 10+ 8+ 7+ 5+ 4+ 2+ + 1 (CRC-32)
32
+ 28+ 27+ 26+ 25+ 23+ 22+ 20+ 19+ 18+ 14+ 13+ 11+ 10+ 9+ 8+
6
+ 1 (CRC-32C)
2
+ 1 (CRC-16)
5
+ 1 (CRC-CCITT)
Figure 1. CRC HAL Module Block Diagram

2. CRC APIs Over view

The CRC HAL module defines APIs for opening, closing, enabling and calculating. A complete list of the available APIs, an exam ple API call and a short description of each can be found in the following table. A table of status return values follows the API summary table.
Table 1. CRC HAL Module API Summary
Close the CRC module driver.
Enable snooping.
R11AN0092EU0102 Rev.1.02 Page 2 of 10 Feb.01.19
Renesas Synergy™ Platform CRC HAL Module Guide
Function Name
Example API Call and Description
.snoopCfg
g_crc.p_api->snoopCfg(g_crc.p_ctrl, g_crc.p_cfg);
Configure the snoop channel and direction.
.calculate
g_crc.p_api->calculate(g_crc.p_ctrl, &input_buffer, .versionGet
g_crc.p_api->versionGet(&version);
Retrieve the API version with the version point er .
Name
Description
SSP_SUCCESS
Configuration was successful.
SSP_ERR_ASSERTION
Assertion error.
SSP_ERR_INVALID_ARGUMENT
Invalid argument error.
SSP_ERR_NOT_OPEN
The driver is not opened.
SSP_ERR_IN_USE
If driver is already open.
num_bytes, crc_seed, &crc_result); Perform a CRC calculation on a block of data.
Note: For details on operation and definitions for the function data structures, typedefs, defines, API data,
API structures, and function variables, review the SSP User’s Manual API References for the associated module.
Table 2. Status Return Values
Note: Lower-level drivers may return common error codes. Refer to the SSP User’s Manual API References
for the associated module for a definition of all relevant status return values.

3. CRC HAL Module Operational Overview

When the CRC HAL module is used to calculate the CRC value for a block of data in memory, the crc_api_t::calculate API ca n be us ed which t ak es the input buf fer poi nter, length and the CR C se ed valu e as input and outputs the calculated CRC value.
When the CRC HAL module is used to calculate CRC on a stream of data being transmitted or received over a serial communication Interface (SCI) channel (snoop mode), the module should be configured to be in snoop mode by calling the crc_api_t::snoopCfg followed by the crc_api_t::snoopEnable APIs. After the requested number of data is transmitted or received on the SCI channel, the calculated CRC value can be polled from the module using the crc_api_t::crcResultGet API.

3.1 CRC HAL Module Important Operational Notes and Limitations

3.1.1 CRC HAL Module Operational Notes

The CRC block does not use any interrupts.
There is no clock configuration for the CRC module.
There are no callbacks for the CRC module.
When using 32-bit CRC polynomials for c alculating CRC values of data bloc k in memory, the data
block is interpreted using little-endian byte order.

3.2 CRC HAL Module Limitations

Refer to the most recent SSP Release Notes for any additional operational limitations for this module.

4. Including the CRC HAL Module in an Application

This section describes how to include the CRC HAL module in an application using the SSP configurator. Note: This section assumes you are familiar with creating a project, adding threads, adding a stack to a
thread and configuring a block within the stack. If you are unfamiliar with any of these items, refer to the first few chapters of the SSP User’s Manual to learn how to manage each of these important
To add the CRC Driver to an application, simply add it to a thread using the stacks selection sequence provided in the following table. (The default name for the CRC Driver is g_crc0. This name can be changed in the associated Properties window.)
R11AN0092EU0102 Rev.1.02 Page 3 of 10 Feb.01.19
steps in creating SSP-based applications.
Renesas Synergy™ Platform CRC HAL Module Guide
Resource
ISDE Tab
Stacks Selection Sequence
r_crc0 CRC Driver on r_crc
Threads
New Stack> Driver> Monitoring> CRC Driver on r_crc
ISDE Property
Value
Description
Parameter Checking
BSP, Enabled, Disabled
Enable or disable the Name
g_crc0
Module name.
CRC Polynomial
CRC-8, CRC-16, CRC-CCITT, CRC-32, CRC-32C
Specify the polynomial to
Bit Order
LSB, MSB
Specify the bit order of
Table 3. CRC Driver Selection Sequence
When the CRC Driver on r_crc is added to the thread stack as shown in the following figure, the configurator automatically adds any needed lower-level modules. Any drivers that need additional configuration inform ation will be box text hig hl ight ed in Red. Mod ul es with a Gray band are individual modules that stand alone.
Figure 2. CRC HAL Module Stack

5. Configuring the CRC H AL Module

The CRC HAL module must be configured by the user for the desired operation. The SSP configuration window will automatically identify (by highlighting the block in red) any required configuration selections, such as interrupts or operating modes, which must be configured for lower-level modules for successful operation. Furthermore, only those properties that can be changed without causing conflicts are available for modification. Other properties are locked and are not available for changes and are identified with a lock icon for the locked property in the Properties window in the ISDE. This approach simplifies the configuration process and makes it much less error prone than previous manual approaches to configuration. The available configuration settings and defaults for all the user-accessible properties are given in the Properties tab within the SSP configurator and are shown in the following tables for easy reference.
One of the properties most often identified as requiring a change is the interrupt priority; this configuration setting is available within the Properties window of the associated module. Simply select the indicated module and then view the Properties window; the interrupt settings are often toward the bottom of the properties list, so scroll down until they become available. Note that the interrupt priorities listed in the Properties window in the ISDE will include an indication as to the validity of the setting based on the targeted MCU (CM4 or CM0+). This level of detail is not included in the following configuration properties tables but is easily visible with the ISDE when configur i ng inter r upt-priority leve ls .
Note: You may want to open your ISDE, create the module and explore the Propert y sett ings in para lle l with
looking over the following configuration table settings. This will help orient you and can be a useful
Table 4. Configuration Settings for the CRC HAL Module on r_crc
hands-on approach to learning the ins and outs of deve lop ing wit h SSP.
Default: BSP
Default: CRC-32C
Default: MSB
Note: The example values and defaults are for a project using the S7G2 Synergy MSU Group. Other MCUs
may have different default values and available configuration settings.
R11AN0092EU0102 Rev.1.02 Page 4 of 10 Feb.01.19
parameter error checking.
use for calculation.
the calculation.
Loading...
+ 7 hidden pages