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

📄 auxtimer.c

📁 Curtiss-Wright Controls Embedded Computing公司的cw183板bsp源代码
💻 C
字号:
/********************************************************************** * *   Copyright (c) 2003-2004, Dy 4 Systems All rights reserved. *   This Source Code is the Property of Dy 4 Systems Inc. and can *   only be used in accordance with Source Code License *   Agreement of Dy 4 Systems Inc. dba (doing business as)  *   CURTISS-WRIGHT CONTROLS EMBEDDED COMPUTING, "CWCEC".  * **********************************************************************//*****************************************************************************  Filename: auxTimer.c  **  Copyright 2004 by DY4 Systems.  All Rights Reserved.**  Project Name: 182 BSP **  Target:  182  **  Description: Standard VxWorks auxiliary timer driver**  Usage:      **  Log: *  Initial revision *  01c,01nov04,tis   add support for CCA-145****************************************************************************/#include "vxWorks.h"#include "config.h"#include "h/drv/timer/fpgaTimer.h"#ifdef VME_182#include "fpga182_dy4.h"#include "intCtrl182_dy4.h"#include "dy4182.h"#endif#ifdef VME_183#include "fpga183.h"#include "intCtrl183.h"#include "cwv183.h"#endif#ifdef CCA_145#include "fpga145.h"#include "intCtrl145.h"#include "cca145.h"#endif/* locals */LOCAL FUNCPTR sysAuxClkRoutine      = NULL;LOCAL int sysAuxClkArg              = 0;LOCAL int sysAuxClkRunning          = FALSE;LOCAL int sysAuxClkTicksPerSecond   = 100; unsigned long auxClkTicks           = 0;LOCAL int auxClkId;/******************************************************************************* 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** NOMANUAL*/LOCAL void sysAuxClkInt (void){    /* call auxiliary clock service routine */    if (sysAuxClkRoutine != NULL)       (*sysAuxClkRoutine) (sysAuxClkArg);}/********************************************************************************* sysAuxClkHwInit - Initialize auxiliary clock timer at HW init level** This routine sets sysAuxId based on CPU ** RETURNS: N/A*/void sysAuxClkHwInit (void){  #ifdef CCA_145    int timerCause;    if (sysProcId == CPU_ID_0)    {        auxClkId = IOFPGA_TIMER0_0;        timerCause =  FPGA_TIMER0_0;    }    else    {        auxClkId = IOFPGA_TIMER1_0;        timerCause  =  FPGA_TIMER1_0;    }        fpgaTimerStop(auxClkId);    fpgaTimerIntClear(auxClkId);    intConnect((void *)(timerCause), (VOIDFUNCPTR)sysAuxClkInt, sysAuxClkArg);#else    if (sysProcId == CPU_ID_0)    {        auxClkId = IOFPGA_TIMER0_0;    }    else    {        auxClkId = IOFPGA_TIMER1_0;    }        fpgaTimerStop(auxClkId);    fpgaTimerIntClear(auxClkId);    intConnect((void *)(FPGA_TIMER0_0 + auxClkId), (VOIDFUNCPTR)sysAuxClkInt, sysAuxClkArg);#endif}/********************************************************************************* 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 */    ){#ifdef CCA_145 int timerCause;     if (sysProcId == CPU_ID_0)    {        timerCause =  FPGA_TIMER0_0;    }    else    {        timerCause  =  FPGA_TIMER1_0;    }    sysAuxClkRoutine = routine;    sysAuxClkArg = arg;    intEnable(timerCause);#else    sysAuxClkRoutine = routine;    sysAuxClkArg = arg;    intEnable(FPGA_TIMER0_0 + auxClkId);#endif    return (OK);}/********************************************************************************* sysAuxClkDisable - turn off auxiliary clock interrupts** This routine disables auxiliary clock interrupts.** RETURNS: N/A** SEE ALSO: sysAuxClkEnable()*/void sysAuxClkDisable (void){    fpgaTimerStop(auxClkId);    fpgaTimerIntClear(auxClkId);    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){    fpgaTimerLoad(auxClkId, FPGA_TIMER_FREQ / sysAuxClkTicksPerSecond);    fpgaTimerIntClear(auxClkId);    fpgaTimerStart(auxClkId);     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);}

⌨️ 快捷键说明

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