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

📄 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 (S1C38K) *	Loop Count Computation of micro Second Wait  */#include <basic.h>#include <sys/sysinfo.h>#include <tk/syslib.h>#include "tkdev_conf.h"/* * Wait loop */LOCAL void WaitLoop( UW count ){	Asm("	_loop:	subs	%0, %0, #1	\n"	"		bhi	_loop		"		: "=r"(count)		: "0"(count + 1)	);}/* * WaitUsec()  Compute loop count of micro second wait *	Suppose that it is executed by interrupt disable. */EXPORT void CountWaitUsec( void ){	UW	mod;	UH	cnt, sc, ec;	/* Select timer */	out_w(TM_SEL, TM_SEL1);	/* Set timer mode/Stop timer */	mod = TMC_FREE|TMC_RELOAD|TMC_DIV16;	out_w(TM1_CTRL, mod);	out_w(TM1_LOAD, 0xffff);	/* Counter initial value */	/* Start timer count */	out_w(TM1_CTRL, mod | TMC_ENA);	/* Measure time for 110000 loops */	sc = in_w(TM1_COUNT);	WaitLoop(110000);	ec = in_w(TM1_COUNT);	cnt = sc - ec;	/* Measure time for 10000 loops */	sc = in_w(TM1_COUNT);	WaitLoop(10000);	ec = in_w(TM1_COUNT);	/* Delete time for operation except for loops and 	   compute the net time for 100000 loops */	cnt -= sc - ec;	/* Stop timer */	out_w(TM1_CTRL, 0);	/* Compute number of loops for 64 micro second	 *			100000 loops	 *	loop64us = ----------------------- * 64usec	 *		    cnt * (16 dividing / TMCLK)	 *	TMCLK = Timer input clock (MHz)	 */	SCInfo.loop64us = TMCLK * 400000 / cnt;}

⌨️ 快捷键说明

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