Comet Labs 48-Port 10 Guía de usuario Pagina 116

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 132
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 115
CIF Peripheral Model - SimpleTimer
112 CoMET Version 5.9 – Tutorial
{
This function is called by the BusWrite and BusUntimedWrite functions. The WriteRegister
function is called each time there is a request to write data to a register from the bus. This
function returns the value put on the bus. Often writing a register signifies the start of some
event in the device. Callback functions are frequently scheduled from the WriteRegister
function.
As in the ReadRegister function, we need to add the case statements to the switch for the
offset of the register write.
The code below contains debug output statements which appear only when the SimpleTimer
module is built in Debug configuration.
Modify the switch (Offset) statement in the WriteRegister function to the following:
CODE BEGINS
switch (Offset)
{
/*
** Determine the register from offset and take appropriate action
*/
case GTR_OFFSET : // General Timer Register
{
tWord32 Count;
#ifdef _DEBUG
AmpiStreamPrintf(DEBUG_MSG, "%s: Write data %#06x to GTR\n",IP-
>pModulePathName,Data);
#endif
// Calculate current counter value.
Count = IP->regGTR + (tWord32)(AmpiClockGetTicks(IP->TimerClock, 0) -
IP->LastCounterUpdateTime);
// Nothing to do if it hasn't changed.
if (Count != Data)
{
// Save the new counter value.
IP->regGTR = Data;
IP->LastCounterUpdateTime = AmpiClockGetTicks(IP->TimerClock, 0);
// Reschedule the next match events.
SetupNextMatch(IP, -1);
}
}
break;
case TER_OFFSET: // Timer Enable Register
#ifdef _DEBUG
AmpiStreamPrintf(DEBUG_MSG, "%s: Write data %#06x to TER\n",IP-
>pModulePathName,Data);
#endif
if (IP->regTER != (Data & TER_ENABLE_ALL))
{
IP->regTER = Data & TER_ENABLE_ALL;
// Clear the match interrupts that are now disabled.
ClearMatchInterrupts(IP, ~Data);
// Reschedule the next match events.
SetupNextMatch(IP, -1);
}
break;
case TIER_OFFSET: // Timer Interrupt Enable Register
Vista de pagina 115
1 2 ... 111 112 113 114 115 116 117 118 119 120 121 ... 131 132

Comentarios a estos manuales

Sin comentarios