User guide
CIF Peripheral Model - SimpleTimer
CoMET Version 5.9 – Tutorial 107
IP->BusClock = AmpiClockInitSlavePortView("BusClock", "All");
IP->Bus = AmpiStdBusInitSlavePortView("Bus", "All");
IP->Reset = AmpiLogicInitSlavePortView("Reset", "All");
Add the following after the IP->Reset line:
CODE BEGINS
IP->TimerClock = AmpiClockInitSlavePortView("TimerClock", "All");
CODE ENDS
Setup callback data structures
In the SimpleTimer.h instance structure we defined CallbackData, an array of
tTimerCallbackData structures, one for each match register. Here we initialize each structure.
After the slave port views input handles section, add the following:
CODE BEGINS
/*
** Set up callback data structures
*/
IP->CallbackData[MATCH1_IX].IP = IP;
IP->CallbackData[MATCH1_IX].regMTRN = MATCH1_IX;
IP->CallbackData[MATCH2_IX].IP = IP;
IP->CallbackData[MATCH2_IX].regMTRN = MATCH2_IX;
CODE ENDS
Register callback handles for match events
In the SimpleTimer.h instance structure we defined callback handle arrays, MatchEvent and
UnmatchEvent. Here we register the callback functions with the scheduler and store the
returned callback handles in the callback handle arrays.
The callback functions section looks similar to the following:
/*
**Register Callback functions if required for any other inputs
*/
In the callback functions section, add the following
CODE BEGINS
IP->MatchEvent[MATCH1_IX] = AmpiTaskRegisterCallback(Match,
(void *)&IP->CallbackData[MATCH1_IX], IP->TimerClock);
IP->MatchEvent[MATCH2_IX] = AmpiTaskRegisterCallback(Match,
(void *)&IP->CallbackData[MATCH2_IX], IP->TimerClock);
IP->UnmatchEvent[MATCH1_IX] = AmpiTaskRegisterCallback(Unmatch,
(void *)&IP->CallbackData[MATCH1_IX], IP->TimerClock);
IP->UnmatchEvent[MATCH2_IX] = AmpiTaskRegisterCallback(Unmatch,
(void *)&IP->CallbackData[MATCH2_IX], IP->TimerClock);
CODE ENDS