📄 cntwus.c
字号:
/* *---------------------------------------------------------------------- * T-Kernel * * Copyright (C) 2004-2006 by Ken Sakamura. All rights reserved. * T-Kernel is distributed under the T-License. *---------------------------------------------------------------------- * * Version: 1.02.02 * Released by T-Engine Forum(http://www.t-engine.org) at 2006/8/9. * *---------------------------------------------------------------------- *//* * cntwus.c (MB87Q1100) * 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 ){ UH cnt, sc, ec; /* Stop timer count */ out_w(TMRCTL, TC_MODE); out_w(TMRIC, 0); /* Initialize counter */ out_w(TMRLD, 0xffffffff); /* Start timer count */ out_w(TMRCTL, TC_TEN|TC_MODE); /* Measure time for 110000 loops */ sc = in_w(TMRVAL); WaitLoop(110000); ec = in_w(TMRVAL); cnt = sc - ec; /* Measure time for 10000 loops */ sc = in_w(TMRVAL); WaitLoop(10000); ec = in_w(TMRVAL); /* Delete time for operation except for loops and compute the net time for 100000 loops */ cnt -= ec - sc; /* Stop timer */ out_w(TMRCTL, 0); /* Compute number of loops for 64 micro second * 100000 loops * loop64us = ----------------------- * 64usec * cnt * (1 / PAclk) * PAclk = Timer input clock (1/100 MHz) */ SCInfo.loop64us = SCInfo.PAclk * 64000 / cnt;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -