MicroZed Chronicles リスト http://adiuvoengineering.com/?page_id=285
@ Adam Taylor blog
https://forums.xilinx.com/t5/Xcell-Daily-Blog/Implementing-the-Zynq-SoC-s-Private-Timer-Adam-Taylor-s-MicroZed/ba-p/402203
例として以下の振舞いを実装しようとしている
In this example, the timer will be loaded and will start running when the button is pressed. (Note: the timer will not be run in auto-reload mode). The timer will generate an interrupt when the preset timer countdown value reaches zero. The resulting interrupt triggers output of a message out over STDOUT and the interrupt will then be cleared to await the next button press.
関連する部分が以下のようだ。
# define TIMER_LOAD_VALUE 0xFFFFFFFF
...
//timer initialization
TMRConfigPtr = XScuTimer_LookupConfig(TIMER_DEVICE_ID);
XScuTimer_CfgInitialize(&Timer, TMRConfigPtr,TMRConfigPtr->BaseAddr);
XScuTimer_SelfTest(&Timer);
//load the timer
XScuTimer_LoadTimer(&Timer, TIMER_LOAD_VALUE);
...
//set up the timer interrupt
XScuGic_Connect(GicInstancePtr, TimerIntrId,
(Xil_ExceptionHandler)TimerIntrHandler,
(void *)TimerInstancePtr);
//enable the interrupt for the Timer at GIC
XScuGic_Enable(GicInstancePtr, TimerIntrId);
//enable interrupt on the timer
XScuTimer_EnableInterrupt(TimerInstancePtr);
...
static void TimerIntrHandler(void *CallBackRef)
{
XScuTimer *TimerInstancePtr = (XScuTimer *) CallBackRef;
XScuTimer_ClearInterruptStatus(TimerInstancePtr);
printf("****Timer Event!!!!!!!!!!!!!****\n\r");
}
...
//load timer
XScuTimer_LoadTimer(&Timer, TIMER_LOAD_VALUE);
//start timer
XScuTimer_Start(&Timer);
上記のうちでわからなかったもののうち、ブログに掲載されている(おそらく動くであろうソースコード)から以下のように整理した。
- TIMER_DEVICE_ID
- #define TIMER_DEVICE_ID XPAR_XSCUTIMER_0_DEVICE_ID
- & TimerのTimer
- static XScuTimer Timer;//timer
- GicInstancePtr
- static XScuGic Intc; //GIC
- static void SetupInterruptSystem(XScuGic *GicInstancePtr, XGpioPs *Gpio, u16 GpioIntrId, ...
- SetupInterruptSystem(&Intc, &Gpio, ...
- TimerIntrId
- #define TIMER_IRPT_INTR XPAR_SCUTIMER_INTR
- TimerInstancePtr
- &Timer
- static XScuTimer Timer;//timer