|
SmartSnippets DA1459x SDK
|
Clock Driver. More...
Modules | |
| CLOCK_TYPES | |
| Clock types. | |
Files | |
| file | hw_clk.h |
| Clock Driver header file. | |
| file | hw_clk_da1459x.h |
| Clock Driver header file. | |
Macros | |
| #define | XTAL32M_USEC_TO_250K_CYCLES(x) ((uint16_t)((x * (dg_configRC32M_FREQ/1000000) + 127) / 128)) |
| Convert settling time (in usec) to XTAL32M_READY counter cycles (250kHz). More... | |
| #define | XTALRDY_CYCLES_TO_LP_CLK_CYCLES(x, lp_freq) ((((uint32_t)(x)) * lp_freq + dg_configRC32M_FREQ_MIN/(128) - 1) / (dg_configRC32M_FREQ_MIN/128)) |
| Convert XTAL32M_READY counter cycles (250kHz) to LP clock cycles. More... | |
Typedefs | |
| typedef enum ahbdiv_type | ahb_div_t |
| The AMBA High-Performance Bus (AHB) clock divider. | |
| typedef enum apbdiv_type | apb_div_t |
| The AMBA Peripheral Bus (APB) clock divider. | |
| typedef enum cal_clk_sel_type | cal_clk_t |
| The type of clock to be calibrated. | |
| typedef enum cal_ref_clk_sel_type | cal_ref_clk_t |
| The reference clock used for calibration. | |
| typedef enum sysclk_type | sys_clk_t |
| The system clock type. More... | |
| typedef enum rclp_mode_type | rclp_mode_t |
| The RCLP mode. More... | |
| typedef enum cpu_clk_type | cpu_clk_t |
| The CPU clock type (speed) More... | |
Enumerations | |
| enum | ahbdiv_type { ahb_div1 = 0, ahb_div2, ahb_div4, ahb_div8, ahb_div16 } |
| The AMBA High-Performance Bus (AHB) clock divider. More... | |
| enum | apbdiv_type { apb_div1 = 0, apb_div2, apb_div4, apb_div8 } |
| The AMBA Peripheral Bus (APB) clock divider. More... | |
| enum | cal_clk_sel_type |
| The type of clock to be calibrated. | |
| enum | cal_ref_clk_sel_type |
| The reference clock used for calibration. | |
| enum | sysclk_type { sysclk_RC32 = 0, sysclk_XTAL32M = 2, sysclk_DBLR64 = 4, sysclk_LP = 255 } |
| The system clock type. More... | |
| enum | rclp_mode_type { RCLP_DEFAULT = 0, RCLP_FORCE_SLOW = REG_MSK(CRG_TOP, CLK_RCLP_REG, RCLP_LOW_SPEED_FORCE), RCLP_FORCE_FAST = REG_MSK(CRG_TOP, CLK_RCLP_REG, RCLP_HIGH_SPEED_FORCE) } |
| The RCLP mode. More... | |
| enum | cpu_clk_type { cpuclk_2M = 2, cpuclk_4M = 4, cpuclk_8M = 8, cpuclk_16M = 16, cpuclk_32M = 32, cpuclk_64M = 64 } |
| The CPU clock type (speed) More... | |
Functions | |
| __STATIC_FORCEINLINE ahb_div_t | hw_clk_get_hclk_div (void) |
| Get the divider of the AMBA High Speed Bus. More... | |
| __STATIC_FORCEINLINE apb_div_t | hw_clk_get_pclk_div (void) |
| Get the divider of the AMBA Peripheral Bus. More... | |
| __STATIC_FORCEINLINE void | hw_clk_set_pclk_div (apb_div_t div) |
| Set the divider of the AMBA Peripheral Bus. More... | |
| __STATIC_INLINE void | hw_clk_set_lpclk (lp_clk_is_t mode) |
| Set Low Power clock. More... | |
| __STATIC_INLINE bool | hw_clk_lpclk_is (lp_clk_is_t clk) |
| Check whether a clock is the Low Power clock. More... | |
| __STATIC_INLINE lp_clk_is_t | hw_clk_get_lpclk (void) |
| Return the clock used as the Low Power clock. More... | |
| __STATIC_INLINE void | hw_clk_configure_lpclk (lp_clk_is_t clk) |
| Configure a Low Power clock. This must be done only once since the register is retained. More... | |
| __STATIC_INLINE void | hw_clk_enable_lpclk (lp_clk_is_t clk) |
| Activate a Low Power clock. More... | |
| __STATIC_INLINE void | hw_clk_disable_lpclk (lp_clk_is_t clk) |
| Deactivate a Low Power clock. More... | |
| __STATIC_FORCEINLINE uint32_t | hw_clk_get_sys_clk_freq (sys_clk_t sys_clk) |
| Get the system clock frequency. More... | |
| __RETAINED_CODE void | hw_clk_delay_usec (uint32_t usec) |
| Add delay of N usecs. More... | |
| __RETAINED_CODE uint32_t | hw_clk_get_sysclk_freq (void) |
| Get current system clock's frequency. More... | |
| __STATIC_INLINE bool | hw_clk_check_rc32_status (void) |
| Check if the RC32M is enabled. More... | |
| __STATIC_INLINE void | hw_clk_enable_rc32 (void) |
| Activate the RC32M. | |
| __STATIC_FORCEINLINE void | hw_clk_disable_rc32 (void) |
| Deactivate the RC32M. | |
| void | hw_clk_set_xtalm_settling_time (uint8_t cycles, bool high_clock) |
| Set the XTAL32M settling time. More... | |
| __STATIC_FORCEINLINE uint16_t | hw_clk_get_xtalm_settling_time (void) |
| Get the XTAL32M settling time (in 250kHz clock cycles). More... | |
| __STATIC_INLINE bool | hw_clk_check_xtalm_status (void) |
| Check if the XTAL32M is enabled. More... | |
| __STATIC_INLINE void | hw_clk_enable_xtalm (void) |
| Activate the XTAL32M. | |
| __STATIC_INLINE void | hw_clk_disable_xtalm (void) |
| Deactivate the XTAL32M. | |
| __STATIC_INLINE bool | hw_clk_is_xtalm_started (void) |
| Check if the XTAL32M has settled. More... | |
| __STATIC_FORCEINLINE sys_clk_is_t | hw_clk_get_sysclk (void) |
| Return the clock used as the system clock. More... | |
| __RETAINED_CODE sys_clk_t | hw_clk_get_system_clock (void) |
| Get the current system clock. More... | |
| __STATIC_INLINE bool | hw_clk_lp_is_xtal32k (void) |
| Check whether the XTAL32K is the Low Power clock. More... | |
| __STATIC_INLINE bool | hw_clk_lp_is_rclp (void) |
| Check whether the RCLP is the Low Power clock. More... | |
| __STATIC_INLINE bool | hw_clk_lp_is_rcx (void) |
| Check whether the RCX is the Low Power clock. More... | |
| __STATIC_INLINE bool | hw_clk_lp_is_external (void) |
| Check whether the RCX is the Low Power clock. More... | |
| __STATIC_INLINE void | hw_clk_lp_set_rcx (void) |
| Set RCX as the Low Power clock. More... | |
| __STATIC_INLINE void | hw_clk_lp_set_xtal32k (void) |
| Set XTAL32K as the Low Power clock. More... | |
| __STATIC_INLINE void | hw_clk_lp_set_ext32k (void) |
| Set an external digital clock as the Low Power clock. More... | |
| __STATIC_INLINE void | hw_clk_set_rclp_mode (rclp_mode_t mode) |
| Configure RCLP. More... | |
| __STATIC_INLINE rclp_mode_t | hw_clk_get_rclp_mode (void) |
| Get RCLP mode of operation. More... | |
| __STATIC_INLINE void | hw_clk_enable_rclp (void) |
| Enable RCLP. | |
| __STATIC_INLINE void | hw_clk_disable_rclp (void) |
| Disable RCLP. More... | |
| __STATIC_INLINE void | hw_clk_lp_set_rclp (void) |
| Set RCLP as the Low Power clock. More... | |
| __STATIC_INLINE void | hw_clk_configure_rcx (void) |
| Configure RCX. This must be done only once since the register is retained. | |
| __STATIC_INLINE void | hw_clk_enable_rcx (void) |
| Enable RCX but does not set it as the LP clock. | |
| __STATIC_INLINE void | hw_clk_disable_rcx (void) |
| Disable RCX. More... | |
| __STATIC_INLINE void | hw_clk_configure_xtal32k (void) |
| Configure XTAL32K. This must be done only once since the register is retained. | |
| __STATIC_INLINE void | hw_clk_enable_xtal32k (void) |
| Enable XTAL32K but do not set it as the LP clock. | |
| __STATIC_INLINE void | hw_clk_disable_xtal32k (void) |
| Disable XTAL32K. More... | |
| __STATIC_INLINE void | hw_clk_calibration_enable_irq (void) |
| Enable the clock calibration interrupt. More... | |
| __STATIC_INLINE void | hw_clk_calibration_clear_irq (void) |
| Clear the clock calibration interrupt. More... | |
| __STATIC_INLINE bool | hw_clk_calibration_status_irq (void) |
| Read the status of the clock calibration interrupt. More... | |
| __STATIC_INLINE bool | hw_clk_calibration_finished (void) |
| Check the status of a requested calibration. More... | |
| void | hw_clk_start_calibration (cal_clk_t clk_type, cal_ref_clk_t clk_ref_type, uint16_t cycles) |
| Start calibration of a clock. More... | |
| uint32_t | hw_clk_get_calibration_data (void) |
| Return the calibration results. More... | |
| __STATIC_INLINE void | hw_clk_set_sysclk (sys_clk_is_t mode) |
| Set System clock. More... | |
| __STATIC_FORCEINLINE void | hw_clk_set_hclk_div (ahb_div_t div) |
| Set the divider of the AMBA High Speed Bus. More... | |
| __STATIC_FORCEINLINE void | hw_clk_dblr_sys_on (void) |
| Enable the Doubler. | |
| __STATIC_FORCEINLINE void | hw_clk_dblr_sys_off (void) |
| Disable the Doubler. More... | |
| __STATIC_INLINE bool | hw_clk_check_dblr_status (void) |
| Check if the Doubler is enabled. More... | |
| __STATIC_INLINE bool | hw_clk_is_dblr_ready (void) |
| Check if the Doubler is available. More... | |
| __STATIC_INLINE void | hw_clk_enable_sysclk (sys_clk_is_t clk) |
| Activate a System clock. More... | |
| __STATIC_INLINE void | hw_clk_disable_sysclk (sys_clk_is_t clk) |
| Deactivate a System clock. More... | |
| __STATIC_INLINE bool | hw_clk_is_enabled_sysclk (sys_clk_is_t clk) |
| Check if a System clock is enabled. More... | |
| __STATIC_FORCEINLINE void | hw_clk_configure_ext32k_pins (void) |
| Configure pin to connect an external digital clock. | |
| int8_t | hw_clk_xtalm_configure_cur_set (void) |
| Configure XTAL32M current setting. More... | |
| void | hw_clk_xtalm_configure_irq (void) |
| Configure XTAL32M IRQ counter start value. More... | |
| __STATIC_INLINE void | hw_clk_xtalm_irq_enable (void) |
| Enable XTAL32M interrupt generation. More... | |
Clock Driver.
| #define XTAL32M_USEC_TO_250K_CYCLES | ( | x | ) | ((uint16_t)((x * (dg_configRC32M_FREQ/1000000) + 127) / 128)) |
Convert settling time (in usec) to XTAL32M_READY counter cycles (250kHz).
| #define XTALRDY_CYCLES_TO_LP_CLK_CYCLES | ( | x, | |
| lp_freq | |||
| ) | ((((uint32_t)(x)) * lp_freq + dg_configRC32M_FREQ_MIN/(128) - 1) / (dg_configRC32M_FREQ_MIN/128)) |
Convert XTAL32M_READY counter cycles (250kHz) to LP clock cycles.
| typedef enum cpu_clk_type cpu_clk_t |
The CPU clock type (speed)
| typedef enum rclp_mode_type rclp_mode_t |
The RCLP mode.
| typedef enum sysclk_type sys_clk_t |
The system clock type.
| enum ahbdiv_type |
| enum apbdiv_type |
| enum cpu_clk_type |
| enum rclp_mode_type |
| enum sysclk_type |
| __STATIC_INLINE void hw_clk_calibration_clear_irq | ( | void | ) |
Clear the clock calibration interrupt.
| __STATIC_INLINE void hw_clk_calibration_enable_irq | ( | void | ) |
Enable the clock calibration interrupt.
| __STATIC_INLINE bool hw_clk_calibration_finished | ( | void | ) |
Check the status of a requested calibration.
| __STATIC_INLINE bool hw_clk_calibration_status_irq | ( | void | ) |
Read the status of the clock calibration interrupt.
| __STATIC_INLINE bool hw_clk_check_dblr_status | ( | void | ) |
Check if the Doubler is enabled.
| __STATIC_INLINE bool hw_clk_check_rc32_status | ( | void | ) |
Check if the RC32M is enabled.
| __STATIC_INLINE bool hw_clk_check_xtalm_status | ( | void | ) |
Check if the XTAL32M is enabled.
| __STATIC_INLINE void hw_clk_configure_lpclk | ( | lp_clk_is_t | clk | ) |
Configure a Low Power clock. This must be done only once since the register is retained.
| [in] | clk | The clock to configure. |
| __STATIC_FORCEINLINE void hw_clk_dblr_sys_off | ( | void | ) |
Disable the Doubler.
| __RETAINED_CODE void hw_clk_delay_usec | ( | uint32_t | usec | ) |
Add delay of N usecs.
| [in] | usec | The number of usecs to wait for. |
| __STATIC_INLINE void hw_clk_disable_lpclk | ( | lp_clk_is_t | clk | ) |
Deactivate a Low Power clock.
| [in] | clk | The clock to deactivate. |
| __STATIC_INLINE void hw_clk_disable_rclp | ( | void | ) |
Disable RCLP.
| __STATIC_INLINE void hw_clk_disable_rcx | ( | void | ) |
Disable RCX.
| __STATIC_INLINE void hw_clk_disable_sysclk | ( | sys_clk_is_t | clk | ) |
Deactivate a System clock.
| [in] | clk | The clock to deactivate. |
| __STATIC_INLINE void hw_clk_disable_xtal32k | ( | void | ) |
Disable XTAL32K.
| __STATIC_INLINE void hw_clk_enable_lpclk | ( | lp_clk_is_t | clk | ) |
Activate a Low Power clock.
| [in] | clk | The clock to activate. |
| __STATIC_INLINE void hw_clk_enable_sysclk | ( | sys_clk_is_t | clk | ) |
Activate a System clock.
| [in] | clk | The clock to activate. |
| uint32_t hw_clk_get_calibration_data | ( | void | ) |
Return the calibration results.
| __STATIC_FORCEINLINE ahb_div_t hw_clk_get_hclk_div | ( | void | ) |
Get the divider of the AMBA High Speed Bus.
| __STATIC_INLINE lp_clk_is_t hw_clk_get_lpclk | ( | void | ) |
Return the clock used as the Low Power clock.
| __STATIC_FORCEINLINE apb_div_t hw_clk_get_pclk_div | ( | void | ) |
Get the divider of the AMBA Peripheral Bus.
| __STATIC_INLINE rclp_mode_t hw_clk_get_rclp_mode | ( | void | ) |
Get RCLP mode of operation.
| __STATIC_FORCEINLINE uint32_t hw_clk_get_sys_clk_freq | ( | sys_clk_t | sys_clk | ) |
Get the system clock frequency.
| [in] | sys_clk | The system clock |
| __STATIC_FORCEINLINE sys_clk_is_t hw_clk_get_sysclk | ( | void | ) |
Return the clock used as the system clock.
| __RETAINED_CODE uint32_t hw_clk_get_sysclk_freq | ( | void | ) |
Get current system clock's frequency.
| __RETAINED_CODE sys_clk_t hw_clk_get_system_clock | ( | void | ) |
Get the current system clock.
| __STATIC_FORCEINLINE uint16_t hw_clk_get_xtalm_settling_time | ( | void | ) |
Get the XTAL32M settling time (in 250kHz clock cycles).
This function reads the start value of the XTAL32M_READY IRQ counter. If the fast clock configuration is used for the counter, the function returns the read value as is. Otherwise, the function adjusts the read value accordingly (so that it represents the equivalent start value in the fast clock case).
| __STATIC_INLINE bool hw_clk_is_dblr_ready | ( | void | ) |
Check if the Doubler is available.
| __STATIC_INLINE bool hw_clk_is_enabled_sysclk | ( | sys_clk_is_t | clk | ) |
Check if a System clock is enabled.
| __STATIC_INLINE bool hw_clk_is_xtalm_started | ( | void | ) |
Check if the XTAL32M has settled.
| __STATIC_INLINE bool hw_clk_lp_is_external | ( | void | ) |
Check whether the RCX is the Low Power clock.
| __STATIC_INLINE bool hw_clk_lp_is_rclp | ( | void | ) |
Check whether the RCLP is the Low Power clock.
| __STATIC_INLINE bool hw_clk_lp_is_rcx | ( | void | ) |
Check whether the RCX is the Low Power clock.
| __STATIC_INLINE bool hw_clk_lp_is_xtal32k | ( | void | ) |
Check whether the XTAL32K is the Low Power clock.
| __STATIC_INLINE void hw_clk_lp_set_ext32k | ( | void | ) |
Set an external digital clock as the Low Power clock.
| __STATIC_INLINE void hw_clk_lp_set_rclp | ( | void | ) |
Set RCLP as the Low Power clock.
| __STATIC_INLINE void hw_clk_lp_set_rcx | ( | void | ) |
Set RCX as the Low Power clock.
| __STATIC_INLINE void hw_clk_lp_set_xtal32k | ( | void | ) |
Set XTAL32K as the Low Power clock.
| __STATIC_INLINE bool hw_clk_lpclk_is | ( | lp_clk_is_t | clk | ) |
Check whether a clock is the Low Power clock.
| [in] | clk | The clock to check. |
| __STATIC_FORCEINLINE void hw_clk_set_hclk_div | ( | ahb_div_t | div | ) |
Set the divider of the AMBA High Speed Bus.
| div | The AMBA High Speed Bus divider |
| __STATIC_INLINE void hw_clk_set_lpclk | ( | lp_clk_is_t | mode | ) |
Set Low Power clock.
| [in] | mode | The new low power clock. |
| __STATIC_FORCEINLINE void hw_clk_set_pclk_div | ( | apb_div_t | div | ) |
Set the divider of the AMBA Peripheral Bus.
| div | The AMBA Peripheral Bus divider |
| __STATIC_INLINE void hw_clk_set_rclp_mode | ( | rclp_mode_t | mode | ) |
Configure RCLP.
| [in] | mode | The mode of the RCLP. |
| __STATIC_INLINE void hw_clk_set_sysclk | ( | sys_clk_is_t | mode | ) |
Set System clock.
| [in] | mode | The new system clock. |
| void hw_clk_set_xtalm_settling_time | ( | uint8_t | cycles, |
| bool | high_clock | ||
| ) |
Set the XTAL32M settling time.
This function configures the start value and the clock (fast or slow) for the XTAL32M_READY IRQ counter.
| cycles | Number of clock cycles |
| high_clock | If true, use 250kHz clock (RC32M divided by 128), else use 31.25kHz clock (RC32M divided by 1024). |
| void hw_clk_start_calibration | ( | cal_clk_t | clk_type, |
| cal_ref_clk_t | clk_ref_type, | ||
| uint16_t | cycles | ||
| ) |
Start calibration of a clock.
| [in] | clk_type | The clock to be calibrated. Must be enabled. |
| [in] | clk_ref_type | The reference clock to USE. |
| [in] | cycles | The number of cycles of the to-be-calibrated clock to be measured using the reference clock. |
| int8_t hw_clk_xtalm_configure_cur_set | ( | void | ) |
Configure XTAL32M current setting.
Find and apply optimum value for XTAL32M_TRIM_REGXTAL32M_CUR_SET (depends on crystal loss). This minimizes phase noise and ensures that the oscillation stays stable.
| void hw_clk_xtalm_configure_irq | ( | void | ) |
Configure XTAL32M IRQ counter start value.
| __STATIC_INLINE void hw_clk_xtalm_irq_enable | ( | void | ) |
Enable XTAL32M interrupt generation.
1.8.16