PSoC 4 Peripheral Driver Library - Alpha

General Description

Functions

cy_en_sysclk_status_t Cy_SysClk_ClkHfSetSource (cy_en_sysclk_clkhf_src_t source)
 Selects the source of the selected ClkHf. More...
 
cy_en_sysclk_clkhf_src_t Cy_SysClk_ClkHfGetSource (void)
 Reports the source of the ClkHf. More...
 
__STATIC_INLINE void Cy_SysClk_ClkHfSetDivider (cy_en_sysclk_dividers_t divider)
 Sets a divider value for ClkHf. More...
 
__STATIC_INLINE cy_en_sysclk_dividers_t Cy_SysClk_ClkHfGetDivider (void)
 Returns the ClkHf divider value. More...
 
uint32_t Cy_SysClk_ClkHfGetFrequency (void)
 Reports the frequency of the ClkHf. More...
 

Function Documentation

◆ Cy_SysClk_ClkHfSetSource()

cy_en_sysclk_status_t Cy_SysClk_ClkHfSetSource ( cy_en_sysclk_clkhf_src_t  source)

Selects the source of the selected ClkHf.

Parameters
sourcecy_en_sysclk_clkhf_src_t
Returns
Error / status code cy_en_sysclk_status_t :
CY_SYSCLK_SUCCESS - the source is successfully set
CY_SYSCLK_INVALID_STATE - the selected clock source is not enabled
CY_SYSCLK_BAD_PARAM - the source parameter is invalid.
Note
Call SystemCoreClockUpdate after this function calling if ClkSys frequency is affected.
Call Cy_SysLib_SetWaitStates before this function calling if ClkSys frequency is increasing.
Call Cy_SysLib_SetWaitStates after this function calling if ClkSys frequency is decreasing.
Function Usage
/* Scenario: If ECO is enabled and sources ClkHf then the ECO needs
* to be disabled and replaced with the IMO for ClkHf
*/
if (Cy_SysClk_EcoIsEnabled()) /* If ECO enabled */
{
if (CY_SYSCLK_CLKHF_IN_ECO == Cy_SysClk_ClkHfGetSource()) /* If ECO sources ClkHf */
{
/* First update the ClkHf clock to IMO */
{
/* Insert error handling */
}
}
/* Disable the ECO */
}

◆ Cy_SysClk_ClkHfGetSource()

cy_en_sysclk_clkhf_src_t Cy_SysClk_ClkHfGetSource ( void  )

Reports the source of the ClkHf.

Returns
cy_en_sysclk_clkhf_src_t
Function Usage
/* Scenario: If ECO is enabled and sources ClkHf then the ECO needs
* to be disabled and replaced with the IMO for ClkHf
*/
if (Cy_SysClk_EcoIsEnabled()) /* If ECO enabled */
{
if (CY_SYSCLK_CLKHF_IN_ECO == Cy_SysClk_ClkHfGetSource()) /* If ECO sources ClkHf */
{
/* First update the ClkHf clock to IMO */
{
/* Insert error handling */
}
}
/* Disable the ECO */
}

◆ Cy_SysClk_ClkHfSetDivider()

__STATIC_INLINE void Cy_SysClk_ClkHfSetDivider ( cy_en_sysclk_dividers_t  divider)

Sets a divider value for ClkHf.

Parameters
dividercy_en_sysclk_dividers_t
Returns
cy_en_sysclk_status_t
Note
Also call Cy_SysClk_ClkHfSetSource to set the clkHf source.
Call SystemCoreClockUpdate after this function calling.
Call Cy_SysLib_SetWaitStates before calling this function if ClkSys frequency is increasing.
Call Cy_SysLib_SetWaitStates after calling this function if ClkSys frequency is decreasing.
Function Usage
/* Scenario: Set ClkHf divider to 8, to reduce frequency and save power */
{
/* Set the ClkHf divider to 8 */
}
/* Check the HFCLK0 frequency */
uint32_t clkHfFreq = Cy_SysClk_ClkHfGetFrequency();

◆ Cy_SysClk_ClkHfGetDivider()

__STATIC_INLINE cy_en_sysclk_dividers_t Cy_SysClk_ClkHfGetDivider ( void  )

Returns the ClkHf divider value.

Returns
cy_en_sysclk_dividers_t
Function Usage
/* Scenario: Set ClkHf divider to 8, to reduce frequency and save power */
{
/* Set the ClkHf divider to 8 */
}
/* Check the HFCLK0 frequency */
uint32_t clkHfFreq = Cy_SysClk_ClkHfGetFrequency();

◆ Cy_SysClk_ClkHfGetFrequency()

uint32_t Cy_SysClk_ClkHfGetFrequency ( void  )

Reports the frequency of the ClkHf.

Returns
The frequency, in Hz.
Note
The reported frequency may be zero, which indicates unknown.
Function Usage
/* Scenario: Set ClkHf divider to 8, to reduce frequency and save power */
{
/* Set the ClkHf divider to 8 */
}
/* Check the HFCLK0 frequency */
uint32_t clkHfFreq = Cy_SysClk_ClkHfGetFrequency();