CAT2 Peripheral Driver Library
SysLib (System Library)

The system libraries provide APIs that can be called in the user application to handle the timing, logical checking or register. More...

Modules

 Macros
 
 Functions
 
 Data Structures
 
 Enumerated Types
 

Detailed Description

The system libraries provide APIs that can be called in the user application to handle the timing, logical checking or register.

The functions and other declarations used in this driver are in cy_syslib.h. You can include cy_pdl.h to get access to all functions and declarations in the PDL.

The SysLib driver contains a set of different system functions. These functions can be called in the application routine. Major features of the system library:

Configuration Considerations

Assertion Usage
Use the CY_ASSERT() macro to check expressions that must be true as long as the program is running correctly. It is a convenient way to insert sanity checks. The CY_ASSERT() macro is defined in the cy_utils.h file which is part of the Core Library (core-lib). The behavior of the macro is as follows: if the expression passed to the macro is false the CPU will be halted.
The PDL source code uses this assert mechanism extensively. It is recommended that you enable asserts when debugging firmware.
Assertion Classes and Levels
The Infineon Core Library defines three assert classes, which correspond to different kinds of parameters. There is a corresponding assert "level" for each class.

Class MacroLevel MacroType of check
CY_ASSERT_CLASS_1 CY_ASSERT_L1 A parameter that could change between different PSoC devices (e.g. the number of clock paths)
CY_ASSERT_CLASS_2 CY_ASSERT_L2 A parameter that has fixed limits such as a counter period
CY_ASSERT_CLASS_3 CY_ASSERT_L3 A parameter that is an enum constant

Firmware defines which ASSERT class is enabled by defining CY_ASSERT_LEVEL. This is a compiler command line argument, similar to how the DEBUG / NDEBUG macro is passed.
Enabling any class also enables any lower-numbered class. CY_ASSERT_CLASS_3 is the default level, and it enables asserts for all three classes. The following example shows the command-line option to enable all the assert levels:

Note
The use of special characters, such as spaces, parenthesis, etc. must be protected with quotes.

After CY_ASSERT_LEVEL is defined, firmware can use one of the three level macros to make an assertion. For example, if the parameter can vary between devices, firmware uses the L1 macro.

CY_ASSERT_L1(clkPath < SRSS_NUM_CLKPATH);

If the parameter has bounds, firmware uses L2.

CY_ASSERT_L2(trim <= CY_CTB_TRIM_VALUE_MAX);

If the parameter is an enum, firmware uses L3.

CY_ASSERT_L3(config->LossAction <= CY_SYSCLK_CSV_ERROR_FAULT_RESET);

Each check uses the appropriate level macro for the kind of parameter being checked. If a particular assert class/level is not enabled, then the assert does nothing.

More Information

Refer to the technical reference manual (TRM).

Changelog

VersionChangesReason for Change
3.20 Updated the flash wait state register configuration in Cy_SysLib_SetWaitStates() for devices with FLASH ECC support. Support for devices with FLASH ECC feature.
3.10 Added Cy_SysLib_GetUniqueId() to fetch silicon unique information. New feature support.
3.0 Removed all the outdated legacy declarations. Major PDL revision.
2.20 Updated Cy_SysLib_SetWaitStates() to enable flash prefetch buffer for the wait states above zero. Speed up code execution.
2.10.2 Corrected source code comments text.
2.10.1 Updated the CY_ASSERT_LX macros implementation. Replaced "0" with "false" in the do{}while(...) macro.
2.10 Updated Cy_SysLib_DelayCycles() with Cortex-M0 devices support. Fixed incorrect delay provided by Cy_SysLib_DelayCycles() on Cortex-M0 devices.
2.0 Removed redundant functions Cy_SysLib_Halt(), Cy_SysLib_AssertFailed() CY_ASSERT() and CY_HALT() functions of the core library should be used instead.
1.0 Initial version