SmartSnippets DA1459x SDK
sys_clock_mgr.h
Go to the documentation of this file.
1 
44 #ifndef SYS_CLOCK_MGR_H_
45 #define SYS_CLOCK_MGR_H_
46 
47 #include <stdint.h>
48 #include <stdbool.h>
49 #include "hw_clk.h"
50 
51 typedef enum {
52  cm_sysclk_div1_clk_in_use,
53  cm_sysclk_ahb_divider_in_use,
54  cm_sysclk_dblr_used_by_task,
55  cm_sysclk_higher_prio_used,
56  cm_sysclk_invalid_clock,
57  cm_sysclk_max_requested,
58  cm_sysclk_not_requested,
59  cm_sysclk_success
60 } cm_sys_clk_status_t;
61 
69 void cm_sys_clk_init(sys_clk_t type);
70 
112 void cm_sys_clk_set_priority(sys_clk_t *sys_clk_prio_array);
113 
161 cm_sys_clk_status_t cm_sys_clk_request(sys_clk_t type);
162 
194 cm_sys_clk_status_t cm_sys_clk_release(sys_clk_t type);
195 
196 
207 
222 
231 
238 
247 
256 
266 
278 void cm_calibrate_rclp(void);
279 
283 void cm_calibrate_rc32m(void);
284 #ifdef OS_PRESENT
285 
292 __RETAINED_CODE uint32_t cm_rcx_us_2_lpcycles(uint32_t usec);
293 
303 uint32_t cm_rcx_us_2_lpcycles_low_acc(uint32_t usec);
304 
305 #endif
306 
313 void cm_wait_xtalm_ready(void);
314 
315 #ifdef OS_PRESENT
316 
319 void cm_rc_clocks_calibration_task_init(void);
320 
321 
328 void cm_lp_clk_init(void);
329 
337 bool cm_lp_clk_is_avail(void);
338 
346 bool cm_lp_clk_is_avail_fromISR(void);
347 
353 void cm_wait_lp_clk_ready(void);
354 
364 __RETAINED_CODE void cm_lp_clk_wakeup(void);
365 
366 #endif /* OS_PRESENT */
367 
368 
374 void cm_wait_dblr_ready(void);
375 
376 
382 __RETAINED_CODE bool cm_poll_xtalm_ready(void);
383 
392 void cm_enable_xtalm(void);
393 
394 
395 /* ---------------------------------------------------------------------------------------------- */
396 
397 /*
398  * Functions intended to be used only by the Clock and Power Manager.
399  */
400 
418 __RETAINED_CODE void cm_sys_clk_sleep(bool entering_sleep);
419 
426 __RETAINED_CODE void cm_halt_until_xtalm_ready(void);
427 
433 void cm_register_xtal_ready_callback(void (*cb)(void));
434 
440 __RETAINED_CODE void cm_halt_until_sysclk_ready(void);
441 
442 #endif /* SYS_CLOCK_MGR_H_ */
443 
cm_ahb_get_clock_divider
ahb_div_t cm_ahb_get_clock_divider(void)
Returns the AMBA High speed Bus clock divider.
cm_cpu_clk_get
cpu_clk_t cm_cpu_clk_get(void)
Returns the CPU clock frequency.
apb_div_t
enum apbdiv_type apb_div_t
The AMBA Peripheral Bus (APB) clock divider.
cm_sys_clk_get_fromISR
sys_clk_t cm_sys_clk_get_fromISR(void)
Returns the sys_clk that the system uses at that moment (interrupt safe version).
cm_sys_clk_set_priority
void cm_sys_clk_set_priority(sys_clk_t *sys_clk_prio_array)
Set the system clock priority.
cm_wait_dblr_ready
void cm_wait_dblr_ready(void)
Block until the Doubler is ready.
cm_poll_xtalm_ready
__RETAINED_CODE bool cm_poll_xtalm_ready(void)
Check if the fast XTAL clock (XTALxxM) is ready.
cm_sys_clk_release
cm_sys_clk_status_t cm_sys_clk_release(sys_clk_t type)
Restores the system clock. It terminates a matching request.
cm_apb_set_clock_divider
void cm_apb_set_clock_divider(apb_div_t div)
Change the divider of the AMBA Peripheral Bus clock.
cm_sys_clk_sleep
__RETAINED_CODE void cm_sys_clk_sleep(bool entering_sleep)
Set the system clock (unprotected).
cm_calibrate_rc32m
void cm_calibrate_rc32m(void)
Calibrate RC32M.
sys_clk_t
enum sysclk_type sys_clk_t
The system clock type.
cm_enable_xtalm
void cm_enable_xtalm(void)
Start the fast XTAL clock (XTALxxM)
ahb_div_t
enum ahbdiv_type ahb_div_t
The AMBA High-Performance Bus (AHB) clock divider.
cm_ahb_set_clock_divider
bool cm_ahb_set_clock_divider(ahb_div_t div)
Change the divider of the AMBA High speed Bus clock.
cm_cpu_clk_get_fromISR
cpu_clk_t cm_cpu_clk_get_fromISR(void)
Returns the CPU clock frequency (interrupt safe).
cm_apb_get_clock_divider
apb_div_t cm_apb_get_clock_divider(void)
Returns the AMBA Peripheral Bus clock divider.
cm_sys_clk_request
cm_sys_clk_status_t cm_sys_clk_request(sys_clk_t type)
Request for system clock switch.
hw_clk.h
Clock Driver header file.
cm_sys_clk_get
sys_clk_t cm_sys_clk_get(void)
Returns the sys_clk that the system uses at that moment.
cm_calibrate_rclp
void cm_calibrate_rclp(void)
Calibrate RCLP.
cm_halt_until_sysclk_ready
__RETAINED_CODE void cm_halt_until_sysclk_ready(void)
Halt until system clock (either PLL or XTAL32M) is ready.
cm_wait_xtalm_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 ...
cm_sys_clk_init
void cm_sys_clk_init(sys_clk_t type)
Initialize clocks after power-up.
cpu_clk_t
enum cpu_clk_type cpu_clk_t
The CPU clock type (speed)
cm_register_xtal_ready_callback
void cm_register_xtal_ready_callback(void(*cb)(void))
Register a callback function to be called then XTAL32M is ready.
cm_halt_until_xtalm_ready
__RETAINED_CODE void cm_halt_until_xtalm_ready(void)
Halt until the fast XTAL clock (XTALxxM) has settled.