当前位置: 技术问答>linux和unix
“timer_ticks_to_usec函数”是干什么的?
来源: 互联网 发布时间:2016-07-29
本文导语: 请高手回答一下: archarmmach-s3c2410time.c文件中的“timer_mask_usec_ticks函数”和“timer_ticks_to_usec函数”是干什么的?希望能说得详细一点,小弟看了一天也没看明白!多谢啦! #define TIMER_USEC_SHIFT 16 /* we use the shifted...
请高手回答一下:
archarmmach-s3c2410time.c文件中的“timer_mask_usec_ticks函数”和“timer_ticks_to_usec函数”是干什么的?希望能说得详细一点,小弟看了一天也没看明白!多谢啦!
#define TIMER_USEC_SHIFT 16
/* we use the shifted arithmetic to work out the ratio of timer ticks
* to usecs, as often the peripheral clock is not a nice even multiple
* of 1MHz.
*
* shift of 14 and 15 are too low for the 12MHz, 16 seems to be ok
* for the current HZ value of 200 without producing overflows.
*
* Original patch by Dimitry Andric, updated by Ben Dooks
*/
/* timer_mask_usec_ticks
*
* given a clock and divisor, make the value to pass into timer_ticks_to_usec
* to scale the ticks into usecs
*/
static inline unsigned long
timer_mask_usec_ticks(unsigned long scaler, unsigned long pclk)
{
unsigned long den = pclk / 1000;
return ((1000 1)) / den;
}
static inline unsigned long timer_ticks_to_usec(unsigned long ticks)
{
unsigned long res;
res = ticks * timer_usec_ticks;
res += 1 TIMER_USEC_SHIFT;
}
archarmmach-s3c2410time.c文件中的“timer_mask_usec_ticks函数”和“timer_ticks_to_usec函数”是干什么的?希望能说得详细一点,小弟看了一天也没看明白!多谢啦!
#define TIMER_USEC_SHIFT 16
/* we use the shifted arithmetic to work out the ratio of timer ticks
* to usecs, as often the peripheral clock is not a nice even multiple
* of 1MHz.
*
* shift of 14 and 15 are too low for the 12MHz, 16 seems to be ok
* for the current HZ value of 200 without producing overflows.
*
* Original patch by Dimitry Andric, updated by Ben Dooks
*/
/* timer_mask_usec_ticks
*
* given a clock and divisor, make the value to pass into timer_ticks_to_usec
* to scale the ticks into usecs
*/
static inline unsigned long
timer_mask_usec_ticks(unsigned long scaler, unsigned long pclk)
{
unsigned long den = pclk / 1000;
return ((1000 1)) / den;
}
static inline unsigned long timer_ticks_to_usec(unsigned long ticks)
{
unsigned long res;
res = ticks * timer_usec_ticks;
res += 1 TIMER_USEC_SHIFT;
}
|
timer_mask_usec_ticks(unsigned long scaler, unsigned long pclk)
给分频器的值和PCLK的值,得到一个值传递给timer_ticks_to_usec,来计算ticks能转换为多少微秒
timer_ticks_to_usec 就是利用timer_mask_usec_ticks的返回值完成ticks到微秒的转换
很抱歉我对24xx的硬件理解还不深,不能详细给你讲清楚
PCLK是APB总线时钟频率
这里的scaler 也不清楚是哪一级的分频器
也许我知道的还没有lz多
给分频器的值和PCLK的值,得到一个值传递给timer_ticks_to_usec,来计算ticks能转换为多少微秒
timer_ticks_to_usec 就是利用timer_mask_usec_ticks的返回值完成ticks到微秒的转换
很抱歉我对24xx的硬件理解还不深,不能详细给你讲清楚
PCLK是APB总线时钟频率
这里的scaler 也不清楚是哪一级的分频器
也许我知道的还没有lz多
|
mark
|
我也想不通,也许这样效率更高吧,没有浮点运算,减少了乘除增加了移位
|
换算cpu频率和userTime的一个常数。
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。