time.c

来自「arm7,44b0芯片的blob程序,适用于学嵌入式linux的新手.」· C语言 代码 · 共 79 行

C
79
字号
/*------------------------------------------------------------------------- * Filename:      time.c * Version:       $Id: time.c,v 1.3 2001/10/07 20:16:57 erikm Exp $ * Copyright:     Copyright (C) 1999, Erik Mouw * Author:        Erik Mouw <J.A.K.Mouw@its.tudelft.nl> * Description:   Some easy timer functions for blob * Created at:    Tue Aug 24 21:08:25 1999 * Modified by:   Erik Mouw <J.A.K.Mouw@its.tudelft.nl> * Modified at:   Sun Oct  3 21:10:21 1999 *-----------------------------------------------------------------------*//* * timer.c: Timer functions for blob * * Copyright (C) 1999 2000 2001  Erik Mouw (J.A.K.Mouw@its.tudelft.nl) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * */#ident "$Id: time.c,v 1.3 2001/10/07 20:16:57 erikm Exp $"#ifdef HAVE_CONFIG_H# include <blob/config.h>#endif#include <blob/arch.h>#include <blob/init.h>#include <blob/led.h>#include <blob/time.h>extern int ticks;void TimerInit(void){	REG(TCFG0) = 0x001e0000;	REG(TCFG1) = 0x00000000;	REG(TCNTB5) = 0x2710;	REG(TCON) = 0x06000000;	REG(TCON) = 0x05000000;	ticks = 1;}/* returns the time in 1/TICKS_PER_SECOND seconds */u32  TimerGetTime(void){//	return ticks*10000 - REG(TCNTO5);	return ticks;}void TimerClearOverflow(void){}void msleep(unsigned int msec){	int tk, start, end;	start = TimerGetTime();//	end = start + 1000;	end = start + msec;	do{		tk = TimerGetTime();	}while(tk<end);}

⌨️ 快捷键说明

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