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

📄 cntwus.c

📁 日本著名的的嵌入式实时操作系统T-Kernel的源码及用户手册。
💻 C
字号:
/* *---------------------------------------------------------------------- *    T-Kernel * *    Copyright (C) 2004 by Ken Sakamura. All rights reserved. *    T-Kernel is distributed under the T-License. *---------------------------------------------------------------------- * *    Version:   1.01.00 *    Released by T-Engine Forum(http://www.t-engine.org) at 2004/6/28. * *---------------------------------------------------------------------- *//* *	cntwus.c (VR5500) *	Loop Count Computation of micro Second Wait  */#include <basic.h>#include <sys/sysinfo.h>#include <tk/syslib.h>#include <tk/sysdef.h>#include "tkdev_conf.h"/* * Wait loop */LOCAL void WaitLoop( UW count ){	Asm("		.set	push		\n"	"		.set	noreorder	\n"	"	_loop:	bnez	%0, _loop	\n"	"		subu	%0, %0, 1	\n"	"		.set	pop		"		: "=r"(count)		: "0"(count)	);}/* * WaitUsec()  Compute loop count of micro second wait *	Suppose that it is executed by interrupt disable. */EXPORT void CountWaitUsec( void ){	UW	cnt, sc, ec;	/* Set timer mode (no pre-scale)/Stop timer */	out_w(GPT0CTRL, 0);	out_w(GPT0VAL, 0xffffffff);	/* Counter initial value */	/* Start timer count */	out_w(GPT0CTRL, GPTC_EN);	WaitLoop(10000);	/* Measure time for 1100000 loops */	sc = in_w(GPT0CNTR);	WaitLoop(1100000);	ec = in_w(GPT0CNTR);	cnt = sc - ec;	/* Measure time for 100000 loops */	sc = in_w(GPT0CNTR);	WaitLoop(100000);	ec = in_w(GPT0CNTR);	/* Delete time for operation except for loops and 	   compute the net time for 1000000 loops */	cnt -= sc - ec;	/* Stop timer */	out_w(GPT0CTRL, 0);	/* Compute number of loops for 64 micro second	 *			1000000 loops	 *	loop64us = ------------------------- * 64usec	 *		    cnt * (1000000 / GPTCLK)	 *	GPTCLK = Timer input clock (Hz)	 */	SCInfo.loop64us = GPTCLK * 64 / cnt;}

⌨️ 快捷键说明

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