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

📄 m8240auxclk.c

📁 VxWorks下的PowerPC 824X系列CPU的bSP包!
💻 C
字号:
/* m8240AuxClk.c - PowerPC/8240 auxiliary timer library *//* Copyright 1984-1999 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01c,17apr02,gjc  Fixing AuxSysTimer01b,29oct01,g_h  Cleaning for T2.201a,08jun99,elk  adapted from ppc8260Timer.c (ver 01a).*//*DESCRIPTIONThis library provides PowerPC/8240 auxiliary clock and timestamp support.The TIMER0 is used for the auxiliary clock and TIMER1 is used forthe timestamp support.To include the auxiliary clock facility, the macro INCLUDE_AUXCLK must bedefined. The macros AUX_CLK_RATE_MIN, and AUX_CLK_RATE_MAX must be defined to provide parameter checking for sysAuxClkRateSet() routine.To include the timestamp timer facility, the macro INCLUDE_TIMESTAMP must bedefined. INCLUDE FILES: timerDev.h, vxPpcLib.h   SEE ALSO:.pG "Configuration"*//* includes */#include "m8240Epic.h"#include "drv/timer/timerDev.h"/* local defines */#ifndef CPU_INT_UNLOCK#    define  CPU_INT_UNLOCK(x)  (intUnlock(x))#endif#ifndef CPU_INT_LOCK#    define  CPU_INT_LOCK(x)  (*x = intlock())#endif#ifndef EPIC_TIMER_CNT#  define EPIC_TIMER_CNT       (DEC_CLOCK_FREQ / 8)#endif/* locals */#ifdef INCLUDE_AUX_CLKLOCAL FUNCPTR   sysAuxClkRoutine        = NULL;LOCAL int       sysAuxClkArg            = 0;LOCAL BOOL      sysAuxClkRunning        = FALSE;LOCAL int       sysAuxClkTicksPerSecond	= 60;LOCAL BOOL      sysAuxClkTimerInit      = FALSE;#endif  /* INCLUDE_AUX_CLK */#ifdef INCLUDE_AUX_CLK/************************************************************************* sysAuxClkInt - auxiliary clock interrupt handler** This routine handles the auxiliary clock interrupt.  It calls a user routine* if one was specified by the routine sysAuxClkConnect().* * RETURNS: N/A*/LOCAL void sysAuxClkInt     (    void    )    {    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 the TIMER0 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    )    {    if (sysAuxClkRunning)        {        /* disable counter */        *M8240_EPIC_GTBC0(EUMB) = LONGSWAP(0xffffffff);        EIEIO;          /* synchronize */          sysAuxClkRunning = FALSE;           /* clock is no longer running */        }    }/************************************************************************* 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)        {        /* disable counter */        *M8240_EPIC_GTBC0(EUMB) = LONGSWAP(0xffffffff);        EIEIO;          /* synchronize */        if (!sysAuxClkTimerInit)            {            /* Interrupt unmasked, priority level set */            *M8240_EPIC_GTVR0(EUMB) = LONGSWAP(INT_VEC_TIMER0 | INT_PRI_TIMER0);            EIEIO;          /* synchronize */            /* Interrupt directed at processor 0 */            *M8240_EPIC_GTD0(EUMB)  = LONGSWAP(0x00000001);            EIEIO;          /* synchronize */            /* Connect interrupt handler */           (void) intConnect (INUM_TO_IVEC(INT_VEC_TIMER0), (VOIDFUNCPTR) sysAuxClkInt, 0);                      sysAuxClkTimerInit = TRUE;           }        /* enable counter and write value to count from */        *M8240_EPIC_GTBC0(EUMB)           = LONGSWAP((EPIC_TIMER_CNT/sysAuxClkTicksPerSecond) & 0x7fffffff);        EIEIO;          /* synchronize */        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 */    )    {    if (ticksPerSecond < AUX_CLK_RATE_MIN || ticksPerSecond > AUX_CLK_RATE_MAX)	return (ERROR);    sysAuxClkTicksPerSecond = ticksPerSecond;    if (sysAuxClkRunning)	{	sysAuxClkDisable ();	sysAuxClkEnable ();	}    return (OK);    }#endif  /* INCLUDE_AUX_CLK */

⌨️ 快捷键说明

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