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

📄 nvr4102rtctimer.c

📁 IXP425的BSP代码
💻 C
字号:
/* nvr4102RTCTimer.c - NEC Vr4102 (RTC) timer driver *//* Copyright 1984-1997 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01b,30dec99,jmw  casting NULL to int to stop compiler warning.01a,11sep97,mem written.*//*DESCRIPTIONThis library contains routines to manipulate the timer functions inthe Vr4102 RTC module.  This library handles auxiliary clockfunctions.The macros AUX_CLK_RATE_MIN, and AUX_CLK_RATE_MAX must be defined toprovide parameter checking for the sysAuxClkRateSet() routines.The RTCLong timer is used for the auxiliary clock.*//* defines */#define RTC_LONG_RATE	32768	/* aux clock counter runs at 32kHz *//* locals */LOCAL int   sysAuxClkTicksPerSecond = 100;	/* default aux timer rate    */LOCAL int   sysAuxClkArg	    = (int)NULL;/* aux clock int routine arg */LOCAL BOOL  sysAuxClkRunning	    = FALSE;	/* sys aux clock enabled flag*/LOCAL FUNCPTR	sysAuxClkRoutine    = NULL;	/* aux clock interpt routine */LOCAL int   sysAuxClkTicks; 		        /* aux clk ticks *//********************************************************************************* sysAuxClkInt - interrupt level processing for auxiliary clock** This routine handles the auxiliary clock interrupt.  It is attached to the* clock interrupt vector by the routine sysAuxClkConnect().* The appropriate routine is called and the interrupt is acknowleged.*/LOCAL void sysAuxClkInt (void)    {    /* clear the RTCLong1 interrupt */        *VR4102_RTCINTREG = VR4102_RTC_RTCINTR1;        if (sysAuxClkRoutine != NULL)	(*sysAuxClkRoutine) (sysAuxClkArg);	/* call system clock routine */    }/********************************************************************************* 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 */    )    {    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)	{	int key;	key = intLock ();	*VR4102_ICU_MSYSINT1REG &= ~VR4102_RTCL1INTR;	sysAuxClkRunning = FALSE;	intUnlock (key);	}    }/********************************************************************************* 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)	{	int i;	int key;	key = intLock ();	sysAuxClkRunning = TRUE;	sysAuxClkTicks = RTC_LONG_RATE / sysAuxClkTicksPerSecond;	for (i = 0; i < 2; ++i)	    {	    /* set RTCLong register */	    *VR4102_RTCL1LREG = sysAuxClkTicks & 0xffff;	    *VR4102_RTCL1HREG = (sysAuxClkTicks >> 16) & 0xff;	    /* set RTCLong counter register */    	    *VR4102_RTCL1CNTLREG = sysAuxClkTicks & 0xffff;	    *VR4102_RTCL1CNTHREG = (sysAuxClkTicks >> 16) & 0xff;	    }	/* enable the RTCLong interrupt */	*VR4102_ICU_MSYSINT1REG |= VR4102_RTCL1INTR;	intUnlock (key);	}    }/********************************************************************************* 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 (((RTC_LONG_RATE / ticksPerSecond) < 4)	|| ((RTC_LONG_RATE / ticksPerSecond) > 0x00ffffff))	return (ERROR);    sysAuxClkTicksPerSecond = ticksPerSecond;    if (sysAuxClkRunning)	{	sysAuxClkDisable ();	sysAuxClkEnable ();	}    return (OK);    }

⌨️ 快捷键说明

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