projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
For at91sam7 family.
[bertos.git]
/
drv
/
timer.h
diff --git
a/drv/timer.h
b/drv/timer.h
index d5bb77437a2fda0c98c578a857057585fa5307c7..cd7aa1b48f6344f8bda8d235a4557b1b901b3f4b 100644
(file)
--- a/
drv/timer.h
+++ b/
drv/timer.h
@@
-42,7
+42,10
@@
#define DRV_TIMER_H
#include <cfg/os.h>
#define DRV_TIMER_H
#include <cfg/os.h>
-#include <cpu/cpu.h>
+#include <cfg/macros.h>
+#include <cpu/attr.h>
+#include <cpu/irq.h>
+
/*
* Include platform-specific binding header if we're hosted.
/*
* Include platform-specific binding header if we're hosted.
@@
-112,7
+115,7
@@
INLINE ticks_t ms_to_ticks(mtime_t ms)
return (ms * TIMER_TICKS_PER_SEC) / 1000;
#else
/* Fast timer: don't overflow ticks_t. */
return (ms * TIMER_TICKS_PER_SEC) / 1000;
#else
/* Fast timer: don't overflow ticks_t. */
- return ms *
((TIMER_TICKS_PER_SEC + 500) /
1000);
+ return ms *
DIV_ROUND(TIMER_TICKS_PER_SEC,
1000);
#endif
}
#endif
}
@@
-124,7
+127,7
@@
INLINE ticks_t us_to_ticks(utime_t us)
return ((us / 1000) * TIMER_TICKS_PER_SEC) / 1000;
#else
/* Fast timer: don't overflow ticks_t. */
return ((us / 1000) * TIMER_TICKS_PER_SEC) / 1000;
#else
/* Fast timer: don't overflow ticks_t. */
- return (us *
((TIMER_TICKS_PER_SEC + 500) /
1000)) / 1000;
+ return (us *
DIV_ROUND(TIMER_TICKS_PER_SEC,
1000)) / 1000;
#endif
}
#endif
}
@@
-156,7
+159,7
@@
INLINE utime_t ticks_to_us(ticks_t ticks)
INLINE hptime_t us_to_hptime(utime_t us)
{
#if TIMER_HW_HPTICKS_PER_SEC > 10000000UL
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);
+ return us *
DIV_ROUND(TIMER_HW_HPTICKS_PER_SEC,
1000000UL);
#else
return (us * ((TIMER_HW_HPTICKS_PER_SEC + 500) / 1000UL) + 500) / 1000UL;
#endif
#else
return (us * ((TIMER_HW_HPTICKS_PER_SEC + 500) / 1000UL) + 500) / 1000UL;
#endif
@@
-166,9
+169,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 / 2) /
TIMER_HW_HPTICKS_PER_SEC);
+ return hpticks *
DIV_ROUND(1000000UL,
TIMER_HW_HPTICKS_PER_SEC);
#else
#else
- return (hpticks * 1000UL) /
((TIMER_HW_HPTICKS_PER_SEC + 500) /
1000UL);
+ return (hpticks * 1000UL) /
DIV_ROUND(TIMER_HW_HPTICKS_PER_SEC,
1000UL);
#endif /* TIMER_HW_HPTICKS_PER_SEC < 100000UL */
}
#endif /* TIMER_HW_HPTICKS_PER_SEC < 100000UL */
}