?? kahluaauxclk.c
字號:
/* kahluaAuxClk.c - Kahlua EPIC Timer (Aux Clk) library *//* Copyright 1999-2002 Wind River Systems, Inc. *//* Copyright 1999 Motorola, Inc. All Rights Reserved */ /*modification history--------------------01g,16apr02,dat Update for T2.2 release01f,15jun00,dmw updated following WRS code review.01e,04jun99,rhk format changes, replace hard coded constants with macros.01d,20apr99,rhk change Raven references to EPIC in comments.01c,23feb99,rhk replace EIEIO macros with SYNC.01b,15feb99,rhk changed defines to use kahlua.h names.01a,12feb99,rhk created from ravenAuxClk.c file in mcp750 BSP.*/ /*DESCRIPTIONThis timer contains routines to use timer 0 on the EPIC as the auxiliaryclock.*//* includes */#include "mv2100.h"/* defines */#define EPIC_TIMER_CNT (DEC_CLOCK_FREQ / 8)/* locals */LOCAL void sysAuxClkInt ();LOCAL STATUS sysAuxClkInit();LOCAL FUNCPTR sysAuxClkRoutine = NULL;LOCAL int sysAuxClkArg = 0;LOCAL int sysAuxClkTicksPerSecond = 60;LOCAL BOOL sysAuxClkConnected = FALSE;LOCAL int sysAuxClkRunning = FALSE;/* externals */IMPORT void sysPciOutLong (UINT32, UINT32);/******************************************************************************** sysAuxClkInt - handle an auxiliary clock interrupt from EPIC timer 0** This routine handles a EPIC timer 0 interrupt. It clears the interrupt* and calls the routine installed by sysAuxClkConnect().** RETURNS: N/A*/ LOCAL void sysAuxClkInt (void) { if (sysAuxClkRoutine != NULL) (*sysAuxClkRoutine) (sysAuxClkArg); } /******************************************************************************* sysAuxClkInit - kahlua aux. clock initialization routine** This routine should be called before calling any other routine in this* module.** RETURNS: OK.*/ LOCAL STATUS sysAuxClkInit (void) { /* disable counter */ sysPciOutLong ((UINT32)EPIC_TIMER0_BASE_CT_REG, (0xffffffff) ); SYNC; /* synchronize */ /* setup timer frequency register */ sysPciOutLong ((UINT32)EPIC_TIMER_FREQ_REG, (UINT32)EPIC_TIMER_CNT); /* interrupt unmasked, priority level 15, vector TIMER0_INT_VEC. */ sysPciOutLong ((UINT32)EPIC_TIMER0_VEC_PRI_REG, (( EPIC_GTVP_PRI_15 | (TIMER0_INT_VEC) ) & ~EPIC_GTVP_M)); /* interrupt directed at processor 0 */ sysPciOutLong ((UINT32)EPIC_TIMER0_DEST_REG, EPIC_GTD_P0); SYNC; /* synchronize */ sysAuxClkRunning = FALSE; return (OK); }/******************************************************************************** sysAuxClkConnect - connect a routine to the auxiliary clock interrupt** This routine specifies the interrupt service routine to be called at each* auxiliary clock interrupt.** RETURNS: OK.** SEE ALSO: intConnect(), sysAuxClkEnable()*/ STATUS sysAuxClkConnect ( FUNCPTR routine, /* routine called at each aux clock interrupt */ int arg /* argument with which to call routine */ ) { sysAuxClkRoutine = routine; sysAuxClkArg = arg; sysAuxClkConnected = TRUE; 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 */ sysPciOutLong ((UINT32)EPIC_TIMER0_BASE_CT_REG, 0xffffffff); SYNC; /* synchronize */ sysAuxClkRunning = FALSE; } }/******************************************************************************** sysAuxClkEnable - turn on auxiliary clock interrupts** This routine enables auxiliary clock interrupts.** RETURNS: N/A** SEE ALSO: sysAuxClkDisable()*/ void sysAuxClkEnable (void) { if (!sysAuxClkRunning) { /* enable counter and write value to count from */ sysPciOutLong ((UINT32)EPIC_TIMER0_BASE_CT_REG, ((EPIC_TIMER_CNT/sysAuxClkTicksPerSecond) & EPIC_GTBC_C_MASK)); SYNC; /* 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 is not* supported, since the auxiliary clock always runs at the same rate as the* system clock.** RETURNS: OK or ERROR.** 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 + -