projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reformat.
[bertos.git]
/
drv
/
timer.h
diff --git
a/drv/timer.h
b/drv/timer.h
index 7e2a628871f7a069f85d9f29a8095dc4244d6781..d5bb77437a2fda0c98c578a857057585fa5307c7 100644
(file)
--- a/
drv/timer.h
+++ b/
drv/timer.h
@@
-158,7
+158,7
@@
INLINE hptime_t us_to_hptime(utime_t us)
#if TIMER_HW_HPTICKS_PER_SEC > 10000000UL
return us * ((TIMER_HW_HPTICKS_PER_SEC + 500000UL) / 1000000UL);
#else
#if TIMER_HW_HPTICKS_PER_SEC > 10000000UL
return us * ((TIMER_HW_HPTICKS_PER_SEC + 500000UL) / 1000000UL);
#else
- return (us *
TIMER_HW_HPTICKS_PER_SEC + 500000UL) / 1000
000UL;
+ return (us *
((TIMER_HW_HPTICKS_PER_SEC + 500) / 1000UL) + 500) / 1
000UL;
#endif
}
#endif
}
@@
-166,9
+166,9
@@
INLINE hptime_t us_to_hptime(utime_t us)
INLINE utime_t hptime_to_us(hptime_t hpticks)
{
#if TIMER_HW_HPTICKS_PER_SEC < 100000UL
INLINE utime_t hptime_to_us(hptime_t hpticks)
{
#if TIMER_HW_HPTICKS_PER_SEC < 100000UL
- return hpticks * (
1000000UL
/ TIMER_HW_HPTICKS_PER_SEC);
+ return hpticks * (
(1000000UL + TIMER_HW_HPTICKS_PER_SEC / 2)
/ TIMER_HW_HPTICKS_PER_SEC);
#else
#else
- return (hpticks * 1000
000UL) / TIMER_HW_HPTICKS_PER_SEC
;
+ return (hpticks * 1000
UL) / ((TIMER_HW_HPTICKS_PER_SEC + 500) / 1000UL)
;
#endif /* TIMER_HW_HPTICKS_PER_SEC < 100000UL */
}
#endif /* TIMER_HW_HPTICKS_PER_SEC < 100000UL */
}