CAT2 Peripheral Driver Library

Functions

void Cy_SysLib_Delay (uint32_t milliseconds)
 The function delays by the specified number of milliseconds. More...
 
void Cy_SysLib_DelayUs (uint16_t microseconds)
 The function delays by the specified number of microseconds. More...
 
void Cy_SysLib_DelayCycles (uint32_t cycles)
 Delays for the specified number of cycles. More...
 
void Cy_SysLib_ClearFlashCacheAndBuffer (void)
 This function invalidates the flash cache and buffer. More...
 
uint32_t Cy_SysLib_GetResetReason (void)
 The function returns the cause for the latest reset(s) that occurred in the system. More...
 
void Cy_SysLib_ClearResetReason (void)
 This function clears the values of RES_CAUSE and RES_CAUSE2.
 
void Cy_SysLib_FaultHandler (uint32_t const *faultStackAddr)
 This function stores the ARM Cortex registers into a non-zero init area for debugging. More...
 
void Cy_SysLib_ProcessingFault (void)
 This function determines how to process the current fault state. More...
 
void Cy_SysLib_SetWaitStates (uint32_t clkHfMHz)
 Sets the number of clock cycles the cache will wait before it samples data coming back from Flash. More...
 
uint32_t Cy_SysLib_EnterCriticalSection (void)
 Cy_SysLib_EnterCriticalSection disables interrupts and returns a value indicating whether the interrupts were previously enabled. More...
 
void Cy_SysLib_ExitCriticalSection (uint32_t savedIntrStatus)
 Re-enables the interrupts if they were enabled before Cy_SysLib_EnterCriticalSection() was called. More...
 
uint64_t Cy_SysLib_GetUniqueId (void)
 This function returns the silicon unique ID. More...
 

Detailed Description

Function Documentation

◆ Cy_SysLib_Delay()

void Cy_SysLib_Delay ( uint32_t  milliseconds)

The function delays by the specified number of milliseconds.

By default, the number of cycles to delay is calculated based on the SystemCoreClock.

Parameters
millisecondsThe number of milliseconds to delay.
Note
The function calls Cy_SysLib_DelayCycles() API to generate a delay. If the function parameter (milliseconds) is bigger than CY_DELAY_MS_OVERFLOW constant, then an additional loop runs to prevent an overflow in parameter passed to Cy_SysLib_DelayCycles() API.

◆ Cy_SysLib_DelayUs()

void Cy_SysLib_DelayUs ( uint16_t  microseconds)

The function delays by the specified number of microseconds.

By default, the number of cycles to delay is calculated based on the SystemCoreClock.

Parameters
microsecondsThe number of microseconds to delay.
Note
If the CPU frequency is a small non-integer number, the actual delay can be up to twice as long as the nominal value. The actual delay cannot be shorter than the nominal one.

◆ Cy_SysLib_DelayCycles()

void Cy_SysLib_DelayCycles ( uint32_t  cycles)

Delays for the specified number of cycles.

The function is implemented in the assembler for each supported compiler.

Parameters
cyclesThe number of cycles to delay.

◆ Cy_SysLib_ClearFlashCacheAndBuffer()

void Cy_SysLib_ClearFlashCacheAndBuffer ( void  )

This function invalidates the flash cache and buffer.

It ensures the valid data is read from flash instead of using outdated data from the cache. The caches' Least Recently Used (LRU) structure is also reset to their default state.

◆ Cy_SysLib_GetResetReason()

uint32_t Cy_SysLib_GetResetReason ( void  )

The function returns the cause for the latest reset(s) that occurred in the system.

The reset causes are taken by reading RES_CAUSE register.

Returns
The cause of a system reset.
Name Value
CY_SYSLIB_RESET_HWWDT 0x00001 (bit0)
CY_SYSLIB_PROT_FAULT 0x00008 (bit3)
CY_SYSLIB_RESET_SOFT 0x00010 (bit4)

◆ Cy_SysLib_FaultHandler()

void Cy_SysLib_FaultHandler ( uint32_t const *  faultStackAddr)

This function stores the ARM Cortex registers into a non-zero init area for debugging.

This function calls Cy_SysLib_ProcessingFault() after storing all information.

Parameters
faultStackAddrThe address of the stack pointer, indicates the lowest address in the fault stack frame to be stored.
Note
This function stores the fault stack frame only for the first occurred fault.
The PDL doesn't provide an API to analyze the stored register values. The user has to add additional functions for the analysis, if necessary.
The CY_ARM_FAULT_DEBUG macro defines if the Fault Handler is enabled. By default it is set to CY_ARM_FAULT_DEBUG_ENABLED and enables the Fault Handler. If there is a necessity to save memory or have some specific custom handler, etc. then CY_ARM_FAULT_DEBUG should be redefined as CY_ARM_FAULT_DEBUG_DISABLED. To do this, the following definition should be added to the compiler Command Line (through the project Build Settings): "-D CY_ARM_FAULT_DEBUG=0".

◆ Cy_SysLib_ProcessingFault()

void Cy_SysLib_ProcessingFault ( void  )

This function determines how to process the current fault state.

By default in case of exception the system will stay in the infinite loop of this function.

Note
This function has the WEAK option, so the user can redefine the function behavior for a custom processing. For example, the function redefinition could be constructed from fault stack processing and NVIC_SystemReset() function call.

◆ Cy_SysLib_SetWaitStates()

void Cy_SysLib_SetWaitStates ( uint32_t  clkHfMHz)

Sets the number of clock cycles the cache will wait before it samples data coming back from Flash.

This function must be called before increasing the SYSCLK clock frequency. It can optionally be called after lowering SYSCLK clock frequency in order to improve the CPU performance.

Parameters
clkHfMHzThe SYSCLK clock frequency in MHz. Specifying a frequency above the supported maximum will set the wait states as for the maximum frequency.

◆ Cy_SysLib_EnterCriticalSection()

uint32_t Cy_SysLib_EnterCriticalSection ( void  )

Cy_SysLib_EnterCriticalSection disables interrupts and returns a value indicating whether the interrupts were previously enabled.

Returns
Returns the current interrupt status. Returns 0 if the interrupts were previously enabled or 1 if the interrupts were previously disabled.
Note
Implementation of Cy_SysLib_EnterCriticalSection manipulates the IRQ enable bit with interrupts still enabled.

◆ Cy_SysLib_ExitCriticalSection()

void Cy_SysLib_ExitCriticalSection ( uint32_t  savedIntrStatus)

Re-enables the interrupts if they were enabled before Cy_SysLib_EnterCriticalSection() was called.

The argument should be the value returned from Cy_SysLib_EnterCriticalSection().

Parameters
savedIntrStatusPuts the saved interrupts status returned by the Cy_SysLib_EnterCriticalSection().

◆ Cy_SysLib_GetUniqueId()

uint64_t Cy_SysLib_GetUniqueId ( void  )

This function returns the silicon unique ID.

The ID includes Die lot[3]#, Die Wafer#, Die X, Die Y, Die Sort# and Die Minor.

Returns
A combined 64-bit unique ID. [63:56] - DIE_MINOR [55:48] - DIE_SORT [47:40] - DIE_Y [39:32] - DIE_X [31:24] - DIE_WAFER [23:16] - DIE_LOT[2] [15: 8] - DIE_LOT[1] [ 7: 0] - DIE_LOT[0]