User guide

CIF Peripheral Model - SimpleTimer
110 CoMET Version 5.9 – Tutorial
** Description:
** Reads a device register. This function assumes that all registers
** are 4-bytes in length. It also assumes that all the registers are
** aligned on a 4-byte boundary.
**
** Parameters:
** IP
** A pointer to the instance data.
**
** Address
** The address of the register to be read.
**
** Untimed
** Flag is true if this function is called by the Untimed read.
**
** Returns:
** The 32-bit value read from the register.
*/
static tWord32 ReadRegister(tInstanceData *IP, const tWord32 Address,
tBoolean Untimed)
{
This function is called by the BusRead and BusUntimedRead functions. The ReadRegister
function is called each time there is a request to read data from a register. The value returned
is the value put on the bus.
CoMET by default creates code that calculates the address Offset and a switch statement that
processes the Offset. Note that when the GTR register is read, the value is calculated.
The code below contains debug output statements which appear only when the SimpleTimer
module is built in Debug configuration.
Modify the switch statement to appear as follows:
CODE BEGINS
case GTR_OFFSET:
Data = IP->regGTR + (tWord32)(AmpiClockGetTicks(IP->TimerClock, 0) -
IP->LastCounterUpdateTime);
#ifdef _DEBUG
AmpiStreamPrintf(DEBUG_MSG,
"%s: Read data %#06x from GTR\n",IP->pModulePathName,Data);
#endif
break;
case TER_OFFSET:
Data = IP->regTER;
#ifdef _DEBUG
AmpiStreamPrintf(DEBUG_MSG,
"%s: Read data %#06x from TER\n",IP->pModulePathName,Data);
#endif
break;
case TIER_OFFSET:
Data = IP->regTIER;
#ifdef _DEBUG
AmpiStreamPrintf(DEBUG_MSG,
"%s: Read data %#06x from TIER\n",IP->pModulePathName,Data);
#endif
break;
case TIFR_OFFSET: