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

📄 timer.c

📁 基于ARM嵌入式系统应用开发实例,生物识别代码
💻 C
字号:
/**************************************************************************************************
 *                                                                          
 * Copyright (c) 2002 - 2003 Isteki Electronics (kunshan) Corp. All rights reserved.      
 *                                                                         
 * FILENAME
 *     timer.c
 *
 * VERSION
 *     1.0
 *
 * DESCRIPTION
 *     This file contains the timer initial routine and timer ISR.
 *
 * DATA STRUCTURES
 *     None
 *
 * FUNCTIONS
 *     1. Fun_TimerX_ISR()
 *     2. Fun_TimerInitialize()
 *
 * HISTORY
 *     10/28/2003		 Ver 1.0 Created by Jim Lin
 *
 * REMARK
 *     None
 *     
 *************************************************************************************************/
#include <stdio.h>
#include "740defs.h"

#define C_Timer
#include "ist.h"

/************************************************/
/*	Name: 	Fun_TimerX_ISR						*/
/*	In:		None								*/
/*	Out:	None								*/
/*	Description: 								*/
/*			Timer interrupt ISR					*/
/************************************************/
void Fun_TimerX_ISR()
{
  cur_ticks++;
  
  if(ValBit(TISR,0)==1)
  {
    TISR = 2; 
  }
	
  if(ValBit(TISR,1)==1)
  {
	TISR = 1; 
  }

  if(cur_ticks >= b_times)
  {
	if(ValBit(TISR,0)==1)
    {
      outpw(TCR0, 0);
	  Disable_Int(TIMERINT0); 
	}
	
	if(ValBit(TISR,1)==1)
	{
      outpw(TCR1, 0);
	  Disable_Int(TIMERINT0+1); 
	}
	
	Flag_timer = True;		//if timers of timer int greater than setup,
							//flag is true
  }

}

/************************************************/
/*	Name: 	Fun_TimerInitialize					*/
/*	In:		channel		:定时器号,0 或 1		*/
/*			total_times	:设定的总中断次数		*/
/*	Out:	None								*/
/*	Description: 								*/
/*			init Timer interrupt				*/
/************************************************/
void Fun_TimerInitialize(int channel,unsigned int total_times)
{
  
  Disable_Int(TIMERINT0+channel); 		//close int
  
  if (channel == 0)
  {
      outpw(TCR0, 0x68000000);							/* CE=1, IE=1, periodic mode, pre-scaler=1 */
      outpw(TICR0, (EXT_CLOCK_RATE / TICKS_PER_SEC));	/* timer initial count */
  }
  else
  {
      outpw(TCR1, 0x68000000);							/* CE=1, IE=1, periodic mode, pre-scaler=1 */
      outpw(TICR1, (EXT_CLOCK_RATE / TICKS_PER_SEC));	/* timer initial count */
  }
  
  cur_ticks = 0;
  b_times = total_times;
  Flag_timer = False;				//default flag is false

  Fun_SetIntISR(TIMERINT0+channel, Fun_TimerX_ISR); //set timer int entry
  Enable_Int(TIMERINT0+channel);		 //open int

} 

⌨️ 快捷键说明

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