⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppc555timer.c

📁 IXP425的BSP代码
💻 C
📖 第 1 页 / 共 2 页
字号:
      return (OK);      }   if (!sysClkRunning)          /* don't have any auxiliary clock ! */      return (ERROR);   sysTimestampRunning = TRUE;   return (OK);   }/********************************************************************************* sysTimestampDisable - disable a timestamp timer interrupt** This routine disables timestamp timer interrupts.** NOTE: This routine has no effect, since the CPU decrementer has no* timestamp timer interrupt.** RETURNS: OK, always.** SEE ALSO: sysTimestampEnable()*/STATUS sysTimestampDisable (void)    {    if (sysTimestampRunning)        sysTimestampRunning = FALSE;    return (OK);    }/********************************************************************************* sysTimestampPeriod - get the period of a timestamp timer ** This routine gets the period of the timestamp timer, in ticks.  The* period, or terminal count, is the number of ticks to which the timestamp* timer counts before rolling over and restarting the counting process.** RETURNS: The period of the timestamp timer in counter ticks.*/UINT32 sysTimestampPeriod (void)    {    /*     * The period of the timestamp depends on the clock rate of the on-chip     * timer (ie the Decrementer reload value).     */        return (decCountVal);    }/********************************************************************************* sysTimestampFreq - get a timestamp timer clock frequency** This routine gets the frequency of the timer clock, in ticks per * second.  The rate of the timestamp timer is set explicitly by the * hardware and typically cannot be altered.** NOTE: Because the PowerPC decrementer clock serves as the timestamp timer,* the decrementer clock frequency is also the timestamp timer frequency.** RETURNS: The timestamp timer clock frequency, in ticks per second.*/UINT32 sysTimestampFreq (void)    {    return (sysDecClkFrequency);    }/********************************************************************************* sysTimestamp - get a timestamp timer tick count** This routine returns the current value of the timestamp timer tick counter.* The tick count can be converted to seconds by dividing it by the return of* sysTimestampFreq().** This routine should be called with interrupts locked.  If interrupts are* not locked, sysTimestampLock() should be used instead.** RETURNS: The current timestamp timer tick count.** SEE ALSO: sysTimestampFreq(), sysTimestampLock()*/UINT32 sysTimestamp (void)    {    return (decCountVal - (INT32) vxDecGet());    }/********************************************************************************* sysTimestampLock - lock interrupts and get the timestamp timer tick count** This routine locks interrupts when the tick counter must be stopped * in order to read it or when two independent counters must be read.  * It then returns the current value of the timestamp timer tick* counter.* * The tick count can be converted to seconds by dividing it by the return of* sysTimestampFreq().** If interrupts are already locked, sysTimestamp() should be* used instead.** RETURNS: The current timestamp timer tick count.** SEE ALSO: sysTimestampFreq(), sysTimestamp()*/UINT32 sysTimestampLock (void)    {    UINT32 currentDecValue;    int oldLevel;    oldLevel = intLock ();                              /* LOCK INTERRUPT */    currentDecValue = vxDecGet();    intUnlock (oldLevel);                               /* UNLOCK INTERRUPT */    return (decCountVal - currentDecValue);    }#endif  /* INCLUDE_TIMESTAMP *//********************************************************************************* sysAuxClkInt - handle an auxiliary clock interrupt** This routine handles an auxiliary clock interrupt.  It acknowledges the* interrupt and calls the routine installed by sysAuxClkConnect().** RETURNS: N/A*/void sysAuxClkInt (void)    {    UINT32 imemBase = vxImemBaseGet();  /* internal memory Base Address */    /* read PS bit in PISCR, and then reset it to terminate int request */    if(*PISCR(imemBase) & PISCR_PS)            *PISCR(imemBase) |= PISCR_PS;    /* call auxiliary clock service routine */    if (sysAuxClkRoutine != NULL)	(*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: intConnect(), sysAuxClkEnable()*/STATUS sysAuxClkConnect    (    FUNCPTR routine,    /* routine called at each aux clock interrupt */    int arg             /* argument to auxiliary clock interrupt routine */    )    {    /* connect the ISR to PIT exception */    sysAuxClkRoutine	= routine;    sysAuxClkArg	= arg;    return (OK);    }/********************************************************************************* sysAuxClkDisable - turn off auxiliary clock interrupts** This routine disables auxiliary clock interrupts.** RETURNS: N/A** SEE ALSO: sysAuxClkEnable()*/void sysAuxClkDisable (void)    {    UINT32 imemBase = vxImemBaseGet();  /* internal memory Base Address */    if (sysAuxClkRunning)        {        *PISCR(imemBase) &= ~PISCR_PIE;      /* disable PIT interrupts */        *PISCR(imemBase) &= ~PISCR_PTE;       /* stop PIT */	intDisable (PIT_INT_LVL); /* disable int controller PIT level */        sysAuxClkRunning = FALSE;        }    }/********************************************************************************* sysAuxClkEnable - turn on auxiliary clock interrupts** This routine enables auxiliary clock interrupts.** RETURNS: N/A** SEE ALSO: sysAuxClkConnect(), sysAuxClkDisable(), sysAuxClkRateSet()*/void sysAuxClkEnable (void)    {    UINT32 imemBase = vxImemBaseGet();  /* internal memory Base Address */    if (!sysAuxClkIntConnected)        {	*PISCR(imemBase) |= PISCR_PIRQ;	/* set PIT int level */        /* connect sysAuxClkInt to PIT interrupt */        (void) intConnect (INUM_TO_IVEC(PIT_INT_LVL), (VOIDFUNCPTR) sysAuxClkInt, NULL);                sysAuxClkIntConnected = TRUE;        }    if (!sysAuxClkRunning)        {        /* clear any pendding PIT int request */        if(*PISCR(imemBase) & PISCR_PS)            *PISCR(imemBase) |= PISCR_PS;        /* set clock divider */	*SCCR(imemBase) &= ~SCCR_RTDIV_MSK;	*SCCR(imemBase) |= SCCR_RTDIV;        /* set counter preload value */        *PITC(imemBase) = (PIT_CLOCK_FREQ / sysAuxClkTicksPerSecond) << 16;         *PISCR(imemBase) |= PISCR_PTE;      /* start PIT */        *PISCR(imemBase) |= PISCR_PIE;      /* enable PIT interrupts */	intEnable (PIT_INT_LVL); /* enable int controller PIT level */        sysAuxClkRunning = TRUE;        }    }/********************************************************************************* 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 */    )    {    /* return ERROR if rate is not supported */    if (ticksPerSecond < AUX_CLK_RATE_MIN || ticksPerSecond > AUX_CLK_RATE_MAX)        return (ERROR);    sysAuxClkTicksPerSecond = ticksPerSecond;    if (sysAuxClkRunning)        {        sysAuxClkDisable ();        sysAuxClkEnable ();        }    return (OK);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -