clk_wiz
Vitis Drivers API Documentation
xclk_wiz_intr_example.c File Reference

Overview

This file contains a design example using the XClk_Wiz driver with interrupts it will generate interrupt for clok glitch, clock overflow and underflow The user should have setup with 2 clocking wizard instances, one instance act as clocking monitor (Enable clock monitor in GUI), In another instance enable dynamic clock reconfiguration.

In the present example XCLK_WIZ_DYN_DEVICE_ID assigned to clock wizard 1. Modify this value as per your dynamic clock reconfiguration Clocking wizard

Note
This example requires an interrupt controller connected to the processor and the MIPI CLK_WIZ in the system.
MODIFICATION HISTORY:

Ver Who Date Changes


1.0 ram 2/12/16 Initial version for Clock Wizard 1.1 ms 01/23/17 Modified xil_printf statement in main function to ensure that "Successfully ran" and "Failed" strings are available in all examples. This is a fix for CR-965028. 1.6 sd 7/7/23 Add SDT support.

Functions

u32 ClkWiz_IntrExample (INTC *IntcInstancePtr, u32 DeviceId)
 This function is the main entry point for the interrupt example using the XClk_Wiz driver. More...
 
int SetupInterruptSystem (INTC *IntcInstancePtr, XClk_Wiz *ClkWizPtr)
 This function setups the interrupt system such that interrupts can occur for the CLK_WIZ device. More...
 
void XClk_Wiz_IntrHandler (void *InstancePtr)
 This function is the interrupt handler for the CLK_WIZ core. More...
 
void XClk_Wiz_InterruptEnable (XClk_Wiz *InstancePtr, u32 Mask)
 XClk_Wiz_InterruptEnable will enable the interrupts present in the interrupt mask passed onto the function. More...
 
int Clk_Wiz_Reconfig (XClk_Wiz_Config *CfgPtr_Dynamic)
 This is the Clk_Wiz_Reconfig function, it will reconfigure frequencies as per input array. More...
 
int Wait_For_Lock (XClk_Wiz_Config *CfgPtr_Dynamic)
 This is the Wait_For_Lock function, it will wait for lock to settle change frequency value. More...
 
void ClkWiz_ClkOutOfRangeEventHandler (void *CallBackRef, u32 Mask)
 This function is called when a clock out of range is received by the CLK_WIZ Subsystem core. More...
 
void ClkWiz_ClkGlitchEventHandler (void *CallBackRef, u32 Mask)
 This function is called when a clock glitch event is received by the CLK_WIZ Subsystem core. More...
 
void ClkWiz_ClkStopEventHandler (void *CallBackRef, u32 Mask)
 This function is called when a clock stop event is received by the CLK_WIZ Subsystem core. More...
 
void Delay (u32 Seconds)
 For Microblaze we use an assembly loop that is roughly the same regardless of optimization level, although caches and memory access time can make the delay vary. More...
 
int main ()
 This is the main function for XClk_Wiz interrupt example. More...
 

Function Documentation

int Clk_Wiz_Reconfig ( XClk_Wiz_Config CfgPtr_Dynamic)

This is the Clk_Wiz_Reconfig function, it will reconfigure frequencies as per input array.

Parameters
CfgPtr_Dynamicprovides pointer to clock wizard dynamic config
Findexprovides the index for Frequency divide register
Sindexprovides the index for Frequency phase register
Returns
  • Error 0 for pass scenario
  • Error > 0 for failure scenario
Note
None

References XClk_Wiz_Config::BaseAddr, and Wait_For_Lock().

Referenced by ClkWiz_IntrExample().

void ClkWiz_ClkGlitchEventHandler ( void *  CallBackRef,
u32  Mask 
)

This function is called when a clock glitch event is received by the CLK_WIZ Subsystem core.

Parameters
CallBackRefcontains a callback reference from the driver. In this case it is the instance pointer for the ClkWiz_Mon driver.
Maskof interrupt which caused this event
Returns
None
Note
None

References XCLK_WIZ_ISR_CLK0_GLITCH_MASK, XCLK_WIZ_ISR_CLK1_GLITCH_MASK, XCLK_WIZ_ISR_CLK2_GLITCH_MASK, and XCLK_WIZ_ISR_CLK3_GLITCH_MASK.

Referenced by ClkWiz_IntrExample(), and SetupInterruptSystem().

void ClkWiz_ClkOutOfRangeEventHandler ( void *  CallBackRef,
u32  Mask 
)

This function is called when a clock out of range is received by the CLK_WIZ Subsystem core.

Parameters
CallBackRefcontains a callback reference from the driver. In this case it is the instance pointer for the ClkWiz_Mon driver.
Maskof interrupt which caused this event
Returns
None
Note
None

References XCLK_WIZ_ISR_CLK0_MAXFREQ_MASK, XCLK_WIZ_ISR_CLK0_MINFREQ_MASK, XCLK_WIZ_ISR_CLK1_MAXFREQ_MASK, XCLK_WIZ_ISR_CLK1_MINFREQ_MASK, XCLK_WIZ_ISR_CLK2_MAXFREQ_MASK, XCLK_WIZ_ISR_CLK2_MINFREQ_MASK, XCLK_WIZ_ISR_CLK3_MAXFREQ_MASK, and XCLK_WIZ_ISR_CLK3_MINFREQ_MASK.

Referenced by ClkWiz_IntrExample(), and SetupInterruptSystem().

void ClkWiz_ClkStopEventHandler ( void *  CallBackRef,
u32  Mask 
)

This function is called when a clock stop event is received by the CLK_WIZ Subsystem core.

Parameters
CallBackRefis a pointer to the XClk_Wiz instance.
Maskof interrupt which caused this event
Returns
None
Note
None

References XCLK_WIZ_ISR_CLK0_STOP_MASK, XCLK_WIZ_ISR_CLK1_STOP_MASK, XCLK_WIZ_ISR_CLK2_STOP_MASK, and XCLK_WIZ_ISR_CLK3_STOP_MASK.

Referenced by ClkWiz_IntrExample(), and SetupInterruptSystem().

u32 ClkWiz_IntrExample ( INTC *  IntcInstancePtr,
u32  DeviceId 
)

This function is the main entry point for the interrupt example using the XClk_Wiz driver.

This function will set up the system with interrupts handlers.

Parameters
DeviceIdis the unique device ID of the CLK_WIZ Subsystem core.
Returns
  • XST_FAILURE if the system setup failed.
  • XST_SUCCESS should never return since this function, if setup was successful, is blocking.
Note
If system setup was successful, this function is blocking in order to illustrate interrupt handling taking place for HPD events.

References XClk_Wiz_Config::BaseAddr, Clk_Wiz_Reconfig(), ClkWiz_ClkGlitchEventHandler(), ClkWiz_ClkOutOfRangeEventHandler(), ClkWiz_ClkStopEventHandler(), XClk_Wiz::Config, Delay(), XClk_Wiz_Config::EnableClkMon, SetupInterruptSystem(), XClk_Wiz_CfgInitialize(), XCLK_WIZ_IER_ALLINTR_MASK, XClk_Wiz_InterruptEnable(), XClk_Wiz_IntrHandler(), XClk_Wiz_LookupConfig(), and XClk_Wiz_SetCallBack().

Referenced by main().

void Delay ( u32  Seconds)

For Microblaze we use an assembly loop that is roughly the same regardless of optimization level, although caches and memory access time can make the delay vary.

Just keep in mind that after resetting or updating the PHY modes, the PHY typically needs time to recover.

Parameters
Numberof seconds to sleep
Returns
None
Note
None

Referenced by ClkWiz_IntrExample().

int main ( )

This is the main function for XClk_Wiz interrupt example.

If the ClkWiz_IntrExample function which sets up the system succeeds, this function will wait for the interrupts. Notify the events

Parameters
None.
Returns
  • XST_FAILURE if the interrupt example was unsuccessful.
Note
Unless setup failed, main will never return since ClkWiz_IntrExample is blocking (it is waiting on interrupts for Hot-Plug-Detect (HPD) events.

References ClkWiz_IntrExample().

int SetupInterruptSystem ( INTC *  IntcInstancePtr,
XClk_Wiz ClkWizPtr 
)

This function setups the interrupt system such that interrupts can occur for the CLK_WIZ device.

This function is application specific since the actual system may or may not have an interrupt controller. The CLK_WIZ could be directly connected to a processor without an interrupt controller. The user should modify this function to fit the application.

Parameters
ClkWizPtrcontains a pointer to the instance of the CLK_WIZ component which is going to be connected to the interrupt controller.
Returns
XST_SUCCESS if successful, otherwise XST_FAILURE.
Note
None

References ClkWiz_ClkGlitchEventHandler(), ClkWiz_ClkOutOfRangeEventHandler(), ClkWiz_ClkStopEventHandler(), XClk_Wiz_IntrHandler(), and XClk_Wiz_SetCallBack().

Referenced by ClkWiz_IntrExample().

int Wait_For_Lock ( XClk_Wiz_Config CfgPtr_Dynamic)

This is the Wait_For_Lock function, it will wait for lock to settle change frequency value.

Parameters
CfgPtr_Dynamicprovides pointer to clock wizard dynamic config
Returns
  • Error 0 for pass scenario
  • Error > 0 for failure scenario
Note
None

References XClk_Wiz_Config::BaseAddr.

Referenced by Clk_Wiz_Reconfig().