?? auxtimer.c
字號:
/***************************************************************************
*
* $RCSfile: auxTimer.c $
*
* Copyright 2001 by Dy 4 Systems, Inc. All Rights Reserved.
*
* $Revision: 1.6 $
*
* $Name: AV4-ISP-R1.2-1 AV4-ISP-R1.2-0 HMTST2 HMTST1 DVT_AV4_4.101 AV4-VSP-R1.0-2 AV4-VSP-R1.0 CT-ISP-1.1 AV4 ISP 1.1 CT_R0.1_AV4/CAV4 champtools2.22 CAV4_CP1 CHAMPtools FW 3.0 champtools2.21_1215 champtools2.21 champ221_build1 champtools2.2 CHAMPtools_2.1.1_AV3 CHAMPtools_2.1_106 CHAMPtools_2.0_AV3 $ $State: Developmental $ $Locker: $
*
* $Source: L:/SWRND/champAV2/src/vx/src/drv/timer/rcs/auxTimer.c $
*
* RCS Project Name:
*
* CSC:
*
* Target:
*
* Description:
*
* Usage:
*
* $Log: auxTimer.c $
* Revision 1.6 2003/08/05 20:03:58Z esaunder
* Modified to utilize AV3 timer resource allocation functions (bslTimerAlloc,
* bslTimerDealloc); timer allocated only while enabled.
* Revision 1.5 2002/03/27 20:02:27 dsessler
*
****************************************************************************/
/* includes */
#include "vxWorks.h"
#include "config.h"
#include "bsl.h"
/* locals */
LOCAL FUNCPTR sysAuxClkRoutine = 0;
LOCAL int sysAuxClkArg = 0;
LOCAL int sysAuxClkTicksPerSecond = 100;
unsigned long auxClkTicks = 0;
char sysAuxClkName[] = "Aux Clock";
int sysAuxClkTimerID = -1;
/*******************************************************************************
*
* sysAuxClkInt - handle an auxiliary clock interrupt
*
* This routine handles an auxiliary clock interrupt. Calls the routine
* installed by sysAuxClkConnect().
*
* RETURNS: N/A
*/
void sysAuxClkInt (void)
{
/* call auxiliary clock service routine */
if (sysAuxClkRoutine != NULL)
(*sysAuxClkRoutine) (sysAuxClkArg);
auxClkTicks += 1;
}
/*******************************************************************************
*
* 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 */
)
{
sysAuxClkArg = arg;
sysAuxClkRoutine = routine;
return (OK);
}
/*******************************************************************************
*
* sysAuxClkDisable - turn off auxiliary clock interrupts
*
* This routine disables auxiliary clock interrupts and releases the
* timer resource.
*
* RETURNS: N/A
*
* Notes: o No-op if the PCI bridge onboard this Champ AV does not support
* enough timer resources.
*
* SEE ALSO: sysAuxClkEnable()
*/
void sysAuxClkDisable (void)
{
if( sysAuxClkTimerID == -1 ) return;
else
{
bslTimerIntDisable( sysAuxClkTimerID );
bslTimerStop( sysAuxClkTimerID );
bslTimerDealloc( sysAuxClkName );
sysAuxClkTimerID = -1;
}
}
/*******************************************************************************
*
* sysAuxClkEnable - turn on auxiliary clock interrupts
*
* This routine enables auxiliary clock interrupts.
*
* RETURNS: N/A
*
* Notes: o No-op if the PCI bridge onboard this Champ AV does not support
* enough timer resources.
*
* SEE ALSO: sysAuxClkConnect(), sysAuxClkDisable(), sysAuxClkRateSet()
*/
void sysAuxClkEnable (void)
{
/** Note: NON_EXCL mode tolerates superfluous calls to sysAuxClkEnable by app. **/
if( bslTimerAlloc( sysAuxClkName, NON_EXCL, &sysAuxClkTimerID ) != BSL_ERROR_NONE )
{
sysAuxClkTimerID = -1;
return;
}
else
{
intConnect( INUM_TO_IVEC( bslTimerToId( sysAuxClkTimerID )), sysAuxClkInt, 0 );
bslTimerSetFreq( sysAuxClkTimerID, sysAuxClkTicksPerSecond );
bslTimerIntEnable( sysAuxClkTimerID );
bslTimerStart( sysAuxClkTimerID );
}
}
/*******************************************************************************
*
* 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 );
if( sysAuxClkTimerID == -1 ) return( ERROR );
sysAuxClkTicksPerSecond = ticksPerSecond;
sysAuxClkDisable ();
sysAuxClkEnable ();
return (OK);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -