User guide
CIF Peripheral Model - SimpleTimer
CoMET Version 5.9 – Tutorial 105
** Parameters
** p
** Pointer to a tTimerCallbackData structure.
*/
static void Match(void *p)
{
tTimerCallbackData *pCallbackData = (tTimerCallbackData *)p;
tInstanceData *IP = pCallbackData->IP;
tWord32 regMTRN = pCallbackData->regMTRN;
/*
** Do nothing if in reset.
*/
if (IP->InReset)
return;
/*
** By definition of the match register, the count register
** must equal the match register.
*/
IP->regGTR = IP->regMTR[regMTRN];
IP->LastCounterUpdateTime = AmpiClockGetTicks(IP->TimerClock, 0);
/*
** Set the interrupt status bit.
*/
IP->regTIFR |= (1 << regMTRN);
/*
** Generate the interrupt.
*/
AmpiLogicWrite(IP->MatchInterrupt[regMTRN], StdLogic1);
#ifdef _DEBUG
AmpiStreamPrintf(DEBUG_MSG,
"%s: Interrupt generated at TimerClock %#d\n",
IP->pModulePathName,IP->LastCounterUpdateTime);
#endif
/*
** Set up a timed event (1 tick later) to clear the match flag.
*/
AmpiTaskScheduleCallbackTicksAfterSync(
IP->UnmatchEvent[regMTRN] , 1, 0);
}
/**
** void Unmatch(void *p)
**
** Called as a scheduled callback one clock tick after a timer match,
** this function schedules the next timer match callback.
**
** Parameters
** p
** Pointer to a tTimerCallbackData structure.
*/
static void Unmatch(void *p)
{
tTimerCallbackData *pCallbackData = (tTimerCallbackData *)p;
/*
** Do nothing if in reset.
*/
if (pCallbackData->IP->InReset)