|
SmartSnippets DA1459x SDK
|
Clock Manager. More...
Files | |
| file | sys_clock_mgr.h |
| Clock Manager header file. | |
Functions | |
| void | cm_sys_clk_init (sys_clk_t type) |
| Initialize clocks after power-up. More... | |
| void | cm_sys_clk_set_priority (sys_clk_t *sys_clk_prio_array) |
| Set the system clock priority. More... | |
| cm_sys_clk_status_t | cm_sys_clk_request (sys_clk_t type) |
| Request for system clock switch. More... | |
| cm_sys_clk_status_t | cm_sys_clk_release (sys_clk_t type) |
| Restores the system clock. It terminates a matching request. More... | |
| void | cm_apb_set_clock_divider (apb_div_t div) |
| Change the divider of the AMBA Peripheral Bus clock. More... | |
| bool | cm_ahb_set_clock_divider (ahb_div_t div) |
| Change the divider of the AMBA High speed Bus clock. More... | |
| sys_clk_t | cm_sys_clk_get (void) |
| Returns the sys_clk that the system uses at that moment. More... | |
| sys_clk_t | cm_sys_clk_get_fromISR (void) |
| Returns the sys_clk that the system uses at that moment (interrupt safe version). More... | |
| apb_div_t | cm_apb_get_clock_divider (void) |
| Returns the AMBA Peripheral Bus clock divider. More... | |
| ahb_div_t | cm_ahb_get_clock_divider (void) |
| Returns the AMBA High speed Bus clock divider. More... | |
| cpu_clk_t | cm_cpu_clk_get (void) |
| Returns the CPU clock frequency. More... | |
| cpu_clk_t | cm_cpu_clk_get_fromISR (void) |
| Returns the CPU clock frequency (interrupt safe). More... | |
| void | cm_calibrate_rclp (void) |
| Calibrate RCLP. | |
| void | cm_calibrate_rc32m (void) |
| Calibrate RC32M. | |
| void | cm_wait_xtalm_ready (void) |
| Block until the fast XTAL clock (XTALxxM) is ready. If the fast XTAL clock (XTALxxM) is running then the function exits immediately. More... | |
| void | cm_wait_dblr_ready (void) |
| Block until the Doubler is ready. More... | |
| __RETAINED_CODE bool | cm_poll_xtalm_ready (void) |
| Check if the fast XTAL clock (XTALxxM) is ready. More... | |
| void | cm_enable_xtalm (void) |
| Start the fast XTAL clock (XTALxxM) More... | |
| __RETAINED_CODE void | cm_sys_clk_sleep (bool entering_sleep) |
| Set the system clock (unprotected). More... | |
| __RETAINED_CODE void | cm_halt_until_xtalm_ready (void) |
| Halt until the fast XTAL clock (XTALxxM) has settled. More... | |
| void | cm_register_xtal_ready_callback (void(*cb)(void)) |
| Register a callback function to be called then XTAL32M is ready. More... | |
| __RETAINED_CODE void | cm_halt_until_sysclk_ready (void) |
| Halt until system clock (either PLL or XTAL32M) is ready. More... | |
Clock Manager.
| ahb_div_t cm_ahb_get_clock_divider | ( | void | ) |
Returns the AMBA High speed Bus clock divider.
| bool cm_ahb_set_clock_divider | ( | ahb_div_t | div | ) |
Change the divider of the AMBA High speed Bus clock.
The frequency of the AHB clock is (system_clock / (1 << cm_ahbclk)). Note: if the SysTick runs then it is the dg_configABORT_IF_SYSTICK_CLK_ERR setting that controls whether the switch will be aborted or not.
| [in] | div | The new value of the AHB divider. |
| apb_div_t cm_apb_get_clock_divider | ( | void | ) |
Returns the AMBA Peripheral Bus clock divider.
| void cm_apb_set_clock_divider | ( | apb_div_t | div | ) |
Change the divider of the AMBA Peripheral Bus clock.
The frequency of the APB clock is (system_clock / (1 << cm_ahbclk)) / (1 << cm_apbclk).
| [in] | div | The new value of the APB divider. |
| cpu_clk_t cm_cpu_clk_get | ( | void | ) |
Returns the CPU clock frequency.
| cpu_clk_t cm_cpu_clk_get_fromISR | ( | void | ) |
Returns the CPU clock frequency (interrupt safe).
| void cm_enable_xtalm | ( | void | ) |
Start the fast XTAL clock (XTALxxM)
Checks if the fast XTAL clock (XTALxxM) is started. If not, it checks if there is a PDC entry for starting the fast XTAL clock (XTALxxM). If there is, it uses PDC to start the fast XTAL clock (XTALxxM). Otherwise, it enables the fast XTAL clock (XTALxxM) using hw_clk_enable_sysclk().
| __RETAINED_CODE void cm_halt_until_sysclk_ready | ( | void | ) |
Halt until system clock (either PLL or XTAL32M) is ready.
It executes a WFI() call waiting for the XTALxxM Ready interrupt and PLL LOCK interrupt if needed.
| __RETAINED_CODE void cm_halt_until_xtalm_ready | ( | void | ) |
Halt until the fast XTAL clock (XTALxxM) has settled.
It executes a WFI() call waiting for the fast XTAL clock (XTALxxM) Ready interrupt. Any other interrupts that hit are served.
| __RETAINED_CODE bool cm_poll_xtalm_ready | ( | void | ) |
Check if the fast XTAL clock (XTALxxM) is ready.
| void cm_register_xtal_ready_callback | ( | void(*)(void) | cb | ) |
Register a callback function to be called then XTAL32M is ready.
cb pointer to the callback function
| sys_clk_t cm_sys_clk_get | ( | void | ) |
Returns the sys_clk that the system uses at that moment.
| sys_clk_t cm_sys_clk_get_fromISR | ( | void | ) |
Returns the sys_clk that the system uses at that moment (interrupt safe version).
| void cm_sys_clk_init | ( | sys_clk_t | type | ) |
Initialize clocks after power-up.
| [in] | type | The clock source to use as the system clock. |
| cm_sys_clk_status_t cm_sys_clk_release | ( | sys_clk_t | type | ) |
Restores the system clock. It terminates a matching request.
If there are other sys_clk requests that are still active (i.e. not released), the system will switch to the one that has the highest priority. Otherwise, it will switch to the initial sys_clk that was specified when cm_sys_clk_init() was called. No change however will be made if Div1 is in use.
| [in] | type | The clock source the system was requested to use, when the matching cm_sys_clk_request() was called. |
| cm_sys_clk_status_t cm_sys_clk_request | ( | sys_clk_t | type | ) |
Request for system clock switch.
This function can be used for system clock switching. It requests from the Clock Manager to use a specific clock source as system clock (sys_clk). If this is possible, the request is accepted and the function switches the sys_clk setting to the selected clock source and returns cm_sysclk_success. Otherwise, the request is rejected and the function returns a value that denotes the reason why the switch was not possible.
The request can be cancelled/released later by calling cm_sys_clk_release(). Until then, the requested sys_clk is protected from any lower priority sys_clk requests (with the priority as defined by cm_sys_clk_set_priority()).
There are two reasons that make the switching of the system clock not possible. Either there is at least one peripheral that currently uses the Div1 clock, or the current system clock has higher priority and is currently in use. In the second case, a successful switch requires a preceding release operation.
If the request involves enabling the fast Xtal clock (XTAL32M), then, apart from powering on the XTAL32M, the function will wait for it to settle before setting it as sys_clk. If the Doubler is requested, the function will also wait for the Doubler to be available.
The Clock Manager will also take care of automatically restoring the sys_clk to the requested setting after each wake-up.
| [in] | type | The clock source to use as sys_clk. |
| void cm_sys_clk_set_priority | ( | sys_clk_t * | sys_clk_prio_array | ) |
Set the system clock priority.
The system clock priority indicates which sys_clk prevails against another one when requesting a new sys_clk using cm_sys_clk_request().
| [in] | sys_clk_prio_array | pointer to array containing the system clock priority (in decreasing order) |
The application can select a different clock priorities order by creating a local temporary priorities struct instance with the clocks in the desired priority order and then call the cm_sys_clk_set_priority() like in the example below. If the priorities are not set by the application before the first call of cm_sys_clk_request() or cm_sys_clk_release(), then the default priorities will be applied.
| __RETAINED_CODE void cm_sys_clk_sleep | ( | bool | entering_sleep | ) |
Set the system clock (unprotected).
It attempts to:
| [in] | entering_sleep | true if the system is going to sleep, else false. |
| void cm_wait_dblr_ready | ( | void | ) |
Block until the Doubler is ready.
| void cm_wait_xtalm_ready | ( | void | ) |
Block until the fast XTAL clock (XTALxxM) is ready. If the fast XTAL clock (XTALxxM) is running then the function exits immediately.
1.8.16