📄 m85xxtimer.c
字号:
* sysClkEnable - turn on system clock interrupts** This routine enables system clock interrupts.** RETURNS: N/A** SEE ALSO: sysClkConnect(), sysClkDisable(), sysClkRateSet()*/void sysClkEnable (void) { if (!sysClkRunning) { /* clear the pending DEC interrupt */ vxTsrSet (TSR_DIS); /* load the DEC counter and DECAR with interval value */ vxDecarSet (decCountVal); vxDecSet (decCountVal); /* Enable the DEC interrupt & enable autoreload */ vxTcrSet (vxTcrGet() | TCR_DIE | TCR_ARE); /* Enable the TBEN in HID0 */ vxHid0Set (vxHid0Get() | _PPC_HID0_TBEN); /* set the running flag */ sysClkRunning = TRUE; } }/***************************************************************************** sysClkDisable - turn off system clock interrupts** This routine disables system clock interrupts.** RETURNS: N/A** SEE ALSO: sysClkEnable()*/void sysClkDisable (void) { if (sysClkRunning) { /* disable the DEC interrupt and auto-reload capability */ vxTcrSet (vxTcrGet() & ~ (TCR_DIE | TCR_ARE)); /* clear the DEC counter and DECAR */ vxDecSet (0); /* clear the pending DEC interrupt */ vxTsrSet (TSR_DIS); /* reset the running flag */ sysClkRunning = FALSE; } }/***************************************************************************** sysClkRateGet - get the system clock rate** This routine returns the system clock rate.** RETURNS: The number of ticks per second of the system clock.** SEE ALSO: sysClkEnable(), sysClkRateSet()*/int sysClkRateGet (void) { return (sysClkTicksPerSecond); }/***************************************************************************** sysClkRateSet - set the system clock rate** This routine sets the interrupt rate of the system clock. It does not* enable system clock interrupts. It is called by usrRoot() in* usrConfig.c.** RETURNS: OK, or ERROR if the tick rate is invalid or the timer cannot* be set.** SEE ALSO: sysClkEnable(), sysClkRateGet()*/STATUS sysClkRateSet ( int ticksPerSecond /* number of clock interrupts per second */ ) { if (ticksPerSecond < SYS_CLK_RATE_MIN || ticksPerSecond > SYS_CLK_RATE_MAX) return (ERROR); /* save the clock speed */ sysClkTicksPerSecond = ticksPerSecond; /* * compute the value to load in the decrementer. The new value will * be loaded into the decrementer after the end of the current period */ decCountVal = sysTimerClkFreq / ticksPerSecond; /* Update the DEC interval FIX 11/27/00 */ vxDecarSet (decCountVal); vxDecSet (decCountVal); return (OK); }/***************************************************************************** sysAuxClkInt - auxiliary clock interrupt handler** This routine handles the auxiliary clock interrupt on the PowerPC Book E* architecture. It is attached to the Fix Interval Timer vector by the* routine sysAuxClkConnect().** RETURNS : N/A*/void sysAuxClkInt (void) { vxFitIntAck (); /* acknowledge FIT interrupt */ /* program TCR with the FIT period */ vxTcrSet ((vxTcrGet() & ~(TCR_FP|TCR_FP_EXT)) | fitPeriodMask); /* execute the system clock routine */ if (sysAuxClkRoutine != NULL) (*(FUNCPTR) sysAuxClkRoutine) (sysAuxClkArg); }/***************************************************************************** sysAuxClkConnect - connect a routine to the auxiliary clock interrupt** This routine specifies the interrupt service routine to be called at* each auxiliary clock interrupt. It does not enable auxiliary clock* interrupts.** RETURNS: OK, or ERROR if the routine cannot be connected to the* interrupt.** SEE ALSO: excIntConnectTimer(), sysAuxClkEnable()*/STATUS sysAuxClkConnect ( FUNCPTR routine, /* routine called at each aux. clock interrupt */ int arg /* argument to auxiliary clock interrupt */ ) { sysAuxClkRoutine = routine; sysAuxClkArg = arg; return (OK); }/***************************************************************************** sysAuxClkEnable - turn on auxiliary clock interrupts** This routine enables auxiliary clock interrupts.** RETURNS: N/A** SEE ALSO: sysAuxClkConnect(), sysAuxClkDisable(), sysAuxClkRateSet()*/void sysAuxClkEnable (void) { if (!sysAuxClkRunning) { /* clear the pending FIT interrupt */ vxTsrSet (TSR_FIS); /* program TCR with the FIT period */ vxTcrSet ((vxTcrGet() & ~(TCR_FP|TCR_FP_EXT)) | fitPeriodMask); /* Enable the FIT interrupt */ vxTcrSet (vxTcrGet() | TCR_FIE); /* set the running flag */ sysAuxClkRunning = TRUE; } }/***************************************************************************** sysAuxClkDisable - turn off auxiliary clock interrupts** This routine disables auxiliary clock interrupts.*** RETURNS: N/A** SEE ALSO: sysAuxClkEnable()*/void sysAuxClkDisable (void) { if (sysAuxClkRunning) { /* disable the FIT interrupt */ vxTcrSet (vxTcrGet() & (~TCR_FIE)); /* clear the pending FIT interrupt */ vxTsrSet (TSR_FIS); /* reset the running flag */ sysAuxClkRunning = FALSE; } }/***************************************************************************** sysAuxClkRateGet - get the auxiliary clock rate** This routine returns the interrupt rate of the auxiliary clock.** RETURNS: The number of ticks per second of the auxiliary clock.** SEE ALSO: sysAuxClkEnable(), sysAuxClkRateSet()*/int sysAuxClkRateGet (void) { return (sysAuxClkTicksPerSecond); }/***************************************************************************** sysAuxClkRateSet - set the auxiliary clock rate** This routine sets the interrupt rate of the auxiliary clock. It does* not enable auxiliary clock interrupts.** RETURNS: OK, or ERROR if the tick rate is invalid or the timer cannot* be set.** SEE ALSO: sysAuxClkEnable(), sysAuxClkRateGet()*/STATUS sysAuxClkRateSet ( int ticksPerSecond /* number of clock interrupts per second */ ) { int ix; int jx = 0; unsigned long long fitPeriod; /* * compute the FIT period. The closest value to <ticksPerSecond> * is being used. */ if (ticksPerSecond < AUX_CLK_RATE_MIN || ticksPerSecond > AUX_CLK_RATE_MAX) return (ERROR); fitPeriod = (sysTimerClkFreq >> 1) / ticksPerSecond; /* get the closest value to ticksPerSecond supported by the FIT */ for (ix = 0; ix < (int) NELEMENTS (fitTable); ix++) { if (fitPeriod <= fitTable [ix].fitPeriod) { if (ix != 0) if ( fitPeriod < ((fitTable [ix].fitPeriod + fitTable [ix-1].fitPeriod)/2)) jx = ix-1; else jx = ix; else jx = ix; break; } if (ix == NELEMENTS (fitTable) - 1) jx = ix; } fitPeriod = fitTable [jx].fitPeriod; /* actual period of the FIT */ fitPeriodMask = fitTable [jx].fpMask; /* Mask to program TCR with */ /* save the clock speed */ sysAuxClkTicksPerSecond = (sysTimerClkFreq >> 1) / fitPeriod; return (OK); }/***************************************************************************** sysWdtInt - watchdog interrupt handler.** This routine handles the watchdog interrupt on the PowerPC Book E* architecture. It is attached to the watchdog timer vector by the* routine sysWdtConnect().** RETURNS : N/A*/LOCAL void sysWdtInt (void) { /* acknowledge WDT interrupt */ vxTsrSet (TSR_WIS); /* execute the watchdog clock routine */ if (sysWdtRoutine != NULL) (*(FUNCPTR) sysWdtRoutine) (sysWdtArg); }/****************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -