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

📄 sysmpc107auxclk.c

📁 Vxworks的bsp软件开发包(基于wrPpmc74xx)
💻 C
字号:
/* epicAuxClk.c - PowerPC/MPC107 Epic auxiliary timer library *//* Copyright 1984-2002 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01a,02may02,lmk  adapted from m8240AuxClk.c (ver 01a).*//*DESCRIPTIONThis library provides PowerPC/MPC107 auxiliary clock.The MPC107 Epic TIMER0 is used for the auxiliary clock.The macros AUX_CLK_RATE_MIN, and AUX_CLK_RATE_MAX must be defined toprovide parameter checking for sysAuxClkRateSet() routine.INCLUDE FILES: mpc107epic.hSEE ALSO:.pG "Configuration"*//* includes */#include "sysMpc107Epic.h"/* local defines */#ifndef EPIC_TIMER_CNT#  define EPIC_TIMER_CNT       (MPC107_CLK_RATE / 8)#endif/* locals */LOCAL FUNCPTR   sysAuxClkRoutine    = NULL;LOCAL int   sysAuxClkArg            = 0;LOCAL BOOL  sysAuxClkRunning        = FALSE;LOCAL int   sysAuxClkTicksPerSecond = 60;/************************************************************************* 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);    }/************************************************************************* sysAuxClkInit - initialize the auxiliary clock** This routine connects the auxiliary clock interrupt handler.  It places* the timer into a disabled state and then connects the handler.** RETURNS: N/A but the default aux clock handler is connected.*/void sysAuxClkInit    (    void    )    {    /* disable counter */    *EPIC_GTBC0 = LONGSWAP(0xffffffff);    EIEIO;          /* synchronize */    sysAuxClkRunning = FALSE;           /* clock is no longer running */    /* Connect interrupt handler */    (void) intConnect (INUM_TO_IVEC(INT_VEC_TMR0), (VOIDFUNCPTR) sysAuxClkInt, 0);    }/************************************************************************* 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 */        *EPIC_GTBC0 = 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 */        *EPIC_GTBC0 = LONGSWAP(0xffffffff);        EIEIO;          /* synchronize */        sysAuxClkRunning = FALSE;           /* clock is no longer running */        }    /* Interrupt unmasked, priority level set */    *EPIC_GTVR0 = LONGSWAP(INT_VEC_TMR0 | INT_PRI_TMR0);    EIEIO;          /* synchronize */    /* Interrupt directed at processor 0 */    *EPIC_GTD0  = LONGSWAP(0x00000001);    EIEIO;          /* synchronize */    /* enable counter and write value to count from */    *EPIC_GTBC0 = 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.** 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);    }

⌨️ 快捷键说明

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