User guide

CIF Peripheral Model - SimpleTimer
CoMET Version 5.9 – Tutorial 103
** Do nothing if in reset.
*/
if (IP->InReset)
return;
/*
** If match register index is -1, set up all match registers.
** Otherwise, set up the requested match register.
*/
if (MTR_ix == -1)
{
size_t j;
for (j = 0; j < lengthof(IP->MatchInterrupt); j++)
{
SetupNextMatch(IP, j);
}
} else if ( MTR_ix >= 0
&&
(tWord32)MTR_ix < lengthof(IP->MatchInterrupt)
)
{
tWord32 Count;
/*
** Cancel any existing "match" events for the match register.
*/
AmpiTaskScheduleCallbackCancel(IP->MatchEvent[MTR_ix]);
/*
** Cancel any existing "unmatch" events for the match register.
*/
AmpiTaskScheduleCallbackCancel(IP->UnmatchEvent[MTR_ix]);
/*
** If match interrupt is disabled OR
** match register is disabled OR
** match interrupt in Active
** Then do nothing
*/
if ( ((IP->regTIER & (1 << MTR_ix)) == 0
||
(IP->regTER & (1 << MTR_ix)) == 0
||
(IP->regTIFR & (1 << MTR_ix)) != 0)
)
return;
/*
** Calculate the current value of counter. IP->regGTR is
** updated only when the register is written or a match occurs.
*/
Count = IP->regGTR
+ (tWord32)(AmpiClockGetTicks(IP->TimerClock, 0)
- IP->LastCounterUpdateTime);
/*
** Calculate time to next match.
*/
if (IP->regMTR[MTR_ix] == Count)
Match((void *)&IP->CallbackData[MTR_ix]);
else
{
tWord32 MatchTicks;