High level interface for interacting with the Cypress power management and system clock configuration.
This driver provides three categories of functionality:
- Retrieval and adjustment of system clock frequencies.
- Control over low power operating modes.
- The ability to disable interrupts during a critical section, and to renable them afterwards.
|
| #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)) |
| |
◆ CYHAL_SYSTEM_RSLT_ERROR
An error occurred in System module
◆ CYHAL_SYSTEM_RSLT_INVALID_CLK_DIVIDER
An error occurred in System module
◆ CYHAL_SYSTEM_RSLT_UNABLE_TO_SET_CLK_FREQ
An error occurred in System module
◆ CYHAL_SYSTEM_RSLT_SRC_CLK_DISABLED
An error occurred in System module
◆ CYHAL_SYSTEM_RSLT_NO_VALID_DIVIDER
An error occurred in System module
◆ 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 | ) |
|
◆ cyhal_system_sleep()
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()
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()
Register the specified handler with the power manager to be notified when the power state changes.
- Parameters
-
| [in] | callback | The handler to notify on power transitions |
- Returns
- The status of the register_callback request
◆ cyhal_system_unregister_callback()
Removes the specified handler from the power manager so no future notification are made.
- Parameters
-
| [in] | callback | The 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] | clock | ID of clock to configure |
| [out] | frequency_hz | The 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] | clock | ID of clock to configure |
| [in] | frequency_hz | The frequency to run the clock at |
- Returns
- The status of the set_frequency request
◆ cyhal_system_clock_set_divider()
Divides the clock frequency by the divider
- Parameters
-
| [in] | clock | The clock to configure divider value for |
| [in] | divider | The divider value to divide the frequency by |
- Returns
- The status of the set_divider request