PSoC 6 Hardware Abstraction Layer (HAL)
SYSTEM (Power Management and System Clock)

General Description

High level interface for interacting with the Cypress power management and system clock configuration.

This driver provides three categories of functionality:

Macros

#define CYHAL_SYSTEM_RSLT_ERROR   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_SYSTEM , 0))
 
#define CYHAL_SYSTEM_RSLT_INVALID_CLK_DIVIDER   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_SYSTEM , 1))
 
#define CYHAL_SYSTEM_RSLT_UNABLE_TO_SET_CLK_FREQ   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_SYSTEM , 2))
 
#define CYHAL_SYSTEM_RSLT_SRC_CLK_DISABLED   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_SYSTEM , 3))
 
#define CYHAL_SYSTEM_RSLT_NO_VALID_DIVIDER   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_SYSTEM , 4))
 

Functions

uint32_t cyhal_system_critical_section_enter (void)
 
void cyhal_system_critical_section_exit (uint32_t oldState)
 
cy_rslt_t cyhal_system_sleep (void)
 
cy_rslt_t cyhal_system_deepsleep (void)
 
cy_rslt_t cyhal_system_register_callback (cyhal_system_callback_t *callback)
 
cy_rslt_t cyhal_system_unregister_callback (cyhal_system_callback_t const *callback)
 
cy_rslt_t cyhal_system_clock_get_frequency (uint8_t clock, uint32_t *frequency_hz)
 
cy_rslt_t cyhal_system_clock_set_frequency (uint8_t clock, uint32_t frequency_hz)
 
cy_rslt_t cyhal_system_clock_set_divider (cyhal_system_clock_t clock, cyhal_system_divider_t divider)
 

Macro Definition Documentation

◆ CYHAL_SYSTEM_RSLT_ERROR

#define CYHAL_SYSTEM_RSLT_ERROR   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_SYSTEM , 0))

An error occurred in System module

◆ CYHAL_SYSTEM_RSLT_INVALID_CLK_DIVIDER

#define CYHAL_SYSTEM_RSLT_INVALID_CLK_DIVIDER   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_SYSTEM , 1))

An error occurred in System module

◆ CYHAL_SYSTEM_RSLT_UNABLE_TO_SET_CLK_FREQ

#define CYHAL_SYSTEM_RSLT_UNABLE_TO_SET_CLK_FREQ   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_SYSTEM , 2))

An error occurred in System module

◆ CYHAL_SYSTEM_RSLT_SRC_CLK_DISABLED

#define CYHAL_SYSTEM_RSLT_SRC_CLK_DISABLED   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_SYSTEM , 3))

An error occurred in System module

◆ CYHAL_SYSTEM_RSLT_NO_VALID_DIVIDER

#define CYHAL_SYSTEM_RSLT_NO_VALID_DIVIDER   (CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CYHAL_RSLT_MODULE_SYSTEM , 4))

An error occurred in System module

Function Documentation

◆ cyhal_system_critical_section_enter()

uint32_t cyhal_system_critical_section_enter ( void  )

Enter a critical section

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

Returns
Returns the state before entering the critical section. This value must be provided to cyhal_system_critical_section_exit() to properly restore the state

◆ cyhal_system_critical_section_exit()

void cyhal_system_critical_section_exit ( uint32_t  oldState)

Exit a critical section

Re-enables the interrupts if they were enabled before cyhal_system_critical_section_enter() was called. The argument should be the value returned from cyhal_system_critical_section_enter().

Parameters
[in]oldStateThe state of interrupts from cyhal_system_critical_section_enter()

◆ cyhal_system_sleep()

cy_rslt_t cyhal_system_sleep ( void  )

Send the device to sleep

The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the system clock to the core is stopped until a reset or an interrupt occurs.

Returns
Returns CY_RSLT_SUCCESS if the processor successfully entered and exited sleep, otherwise error

◆ cyhal_system_deepsleep()

cy_rslt_t cyhal_system_deepsleep ( void  )

Send the device to deep sleep

This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode has the same sleep features as sleep plus it powers down peripherals and clocks. All state is still maintained.

Returns
Returns CY_RSLT_SUCCESS if the processor successfully entered and exited sleep, otherwise error

◆ cyhal_system_register_callback()

cy_rslt_t cyhal_system_register_callback ( cyhal_system_callback_t *  callback)

Register the specified handler with the power manager to be notified when the power state changes.

Parameters
[in]callbackThe handler to notify on power transitions
Returns
The status of the register_callback request

◆ cyhal_system_unregister_callback()

cy_rslt_t cyhal_system_unregister_callback ( cyhal_system_callback_t const *  callback)

Removes the specified handler from the power manager so no future notification are made.

Parameters
[in]callbackThe handler to remove from receiving notifications
Returns
The status of the unregister_callback request

◆ cyhal_system_clock_get_frequency()

cy_rslt_t cyhal_system_clock_get_frequency ( uint8_t  clock,
uint32_t *  frequency_hz 
)

Gets the specified clock's current frequency.

Parameters
[in]clockID of clock to configure
[out]frequency_hzThe frequency the clock is currently running at
Returns
The status of the get_frequency request

◆ cyhal_system_clock_set_frequency()

cy_rslt_t cyhal_system_clock_set_frequency ( uint8_t  clock,
uint32_t  frequency_hz 
)

Sets the specified clock's frequency and enables it. This will turn on any additional clocks needed to drive this.

Parameters
[in]clockID of clock to configure
[in]frequency_hzThe frequency to run the clock at
Returns
The status of the set_frequency request

◆ cyhal_system_clock_set_divider()

cy_rslt_t cyhal_system_clock_set_divider ( cyhal_system_clock_t  clock,
cyhal_system_divider_t  divider 
)

Divides the clock frequency by the divider

Parameters
[in]clockThe clock to configure divider value for
[in]dividerThe divider value to divide the frequency by
Returns
The status of the set_divider request