Interface for enabling or disabling the clock and updating the clock frequency.
interface, both directly and passing to a HAL driver to manipulate.
uint32_t my_custom_get_clock_freq(const void* clk)
{
CY_UNUSED_PARAMETER(clk);
return 100000;
}
cy_rslt_t my_custom_set_clock_freq(
const void* clk, uint32_t frequency, uint32_t tolerance_ppm)
{
CY_UNUSED_PARAMETER(clk);
CY_UNUSED_PARAMETER(frequency);
CY_UNUSED_PARAMETER(tolerance_ppm);
}
cy_rslt_t my_custom_set_clock_enabled(
const void* clk,
bool enable)
{
CY_UNUSED_PARAMETER(clk);
CY_UNUSED_PARAMETER(enable);
}
#define my_clk_GRP_NUM (0)
#define my_clk_HW (0)
#define my_clk_NUM (0)
void snippet_mtb_hal_clock_custom_interface(void)
{
uint32_t current_freq_hz = 0;
uint32_t target_freq_hz = 100000;
uint32_t tolerance_ppm = 20000;
cy_stc_scb_uart_context_t uart_context;
{
.
clk_dst = (en_clk_dst_t)my_clk_GRP_NUM,
.div_type = (cy_en_divider_types_t)my_clk_HW,
.div_num = my_clk_NUM
};
{
.set_frequency_hz = my_custom_set_clock_freq,
.set_enabled = my_custom_set_clock_enabled
};
{
.interface = &interface
};
if (current_freq_hz != target_freq_hz)
{
tolerance_ppm);
{
}
}
result = mtb_hal_uart_setup(&uart_obj, &UART_hal_config, &uart_context, &clock_obj);
}
cy_rslt_t mtb_hal_uart_set_baud(mtb_hal_uart_t *obj, uint32_t baudrate, uint32_t *actualbaud)
Configure the baud rate.
Definition: mtb_hal_uart.c:568
uint32_t cy_rslt_t
Provides the result of an operation as a structured bitfield.
Definition: cy_result.h:457
#define CY_RSLT_SUCCESS
cy_rslt_t return value indicating success
Definition: cy_result.h:484
Clock Interface structure for clocks.
Definition: mtb_hal_hw_types_clock_srss.h:68
mtb_hal_clock_set_frequency_hz_t set_frequency_hz
Set the clock frequency.
Definition: mtb_hal_hw_types_clock_srss.h:70
mtb_hal_clock_set_enabled_t set_enabled
Enable or Disable the clock.
Definition: mtb_hal_hw_types_clock_srss.h:71
mtb_hal_clock_get_frequency_hz_t get_frequency_hz
Get the clock frequency.
Definition: mtb_hal_hw_types_clock_srss.h:69
Clock object Application shall provide implementations for the functions needed by the clock object.
Definition: mtb_hal_hw_types_clock_srss.h:80
const mtb_hal_clock_interface_t * interface
Struct of interface functions that should be used with this clock.
Definition: mtb_hal_hw_types_clock_srss.h:85
const void * clock_ref
Pointer that is passed to all interface functions.
Definition: mtb_hal_hw_types_clock_srss.h:83
Clock Reference Structure in case of peri divider.
Definition: mtb_hal_hw_types_clock_srss.h:45
en_clk_dst_t clk_dst
PDL uses the target IP to identify the peri group.
Definition: mtb_hal_hw_types_clock_srss.h:46
UART configurator struct.
Definition: mtb_hal_hw_types_uart_scb.h:92
UART object.
Definition: mtb_hal_hw_types_uart_scb.h:66
The clock driver is a single interface designed to allow reading and configuring any clock in the system.
|
cy_rslt_t | mtb_hal_clock_set_enabled (mtb_hal_clock_t *clock, bool enabled, bool wait_for_lock) |
| Attempts to update the enablement of the specified clock. More...
|
|
cy_rslt_t | mtb_hal_clock_set_frequency (mtb_hal_clock_t *clock, uint32_t hz, const mtb_hal_clock_tolerance_t *tolerance) |
| Attempts to update the operating frequency of the clock. More...
|
|
uint32_t | mtb_hal_clock_get_peri_clock_freq (const void *clk) |
| Gets the frequency in hertz the peripheral clock is currently operating at. More...
|
|
cy_rslt_t | mtb_hal_clock_set_peri_clock_freq (const void *clk, uint32_t frequency, uint32_t tolerance_ppm) |
| Update the operating frequency of the peripheral clock. More...
|
|
cy_rslt_t | mtb_hal_clock_set_peri_clock_enabled (const void *clk, bool enable) |
| Enable/Disable the peripheral clock. More...
|
|
uint32_t | mtb_hal_clock_get_peri_src_clock_freq (const void *clk) |
| Gets the peripheral source clock frequency that is feeding the clock tree for the specified resource. More...
|
|
uint32_t | mtb_hal_clock_get_hf_clock_freq (const void *clk) |
| Gets the frequency in hertz the high frequency clock is currently operating at. More...
|
|
cy_rslt_t | mtb_hal_clock_set_hf_clock_freq (const void *clk, uint32_t frequency, uint32_t tolerance_ppm) |
| Update the operating frequency of the high frequency clock. More...
|
|
cy_rslt_t | mtb_hal_clock_set_hf_clock_enabled (const void *clk, bool enable) |
| Enable/Disable the high frequency clock. More...
|
|