diff options
author | Alan Cudmore <alan.cudmore@gmail.com> | 2013-03-23 19:13:07 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2013-03-24 12:57:44 +0100 |
commit | c32b1efa43e31bd9a8a7eae3623664d00c34d842 (patch) | |
tree | e301796d2fb132b0fab24c752072cc2a7ba6e074 /c/src/lib/libbsp/arm/raspberrypi/misc | |
parent | libfs: Always use geteuid() and getegid() (diff) | |
download | rtems-c32b1efa43e31bd9a8a7eae3623664d00c34d842.tar.bz2 |
bsp/raspberrypi: New BSP
Diffstat (limited to 'c/src/lib/libbsp/arm/raspberrypi/misc')
-rw-r--r-- | c/src/lib/libbsp/arm/raspberrypi/misc/timer.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/arm/raspberrypi/misc/timer.c b/c/src/lib/libbsp/arm/raspberrypi/misc/timer.c new file mode 100644 index 0000000000..a26be2f7a7 --- /dev/null +++ b/c/src/lib/libbsp/arm/raspberrypi/misc/timer.c @@ -0,0 +1,49 @@ +/** + * @file + * + * @ingroup raspberrypi + * + * @brief Benchmark timer support. + */ + +/* + * Copyright (c) 2013 by Alan Cudmore + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * + * http://www.rtems.com/license/LICENSE + * + */ + +#include <rtems.h> +#include <rtems/timerdrv.h> +#include <bsp/raspberrypi.h> + +static bool benchmark_timer_find_average_overhead = false; + +static uint64_t benchmark_timer_base; + +void benchmark_timer_initialize(void) +{ + benchmark_timer_base = BCM2835_REG(BCM2835_GPU_TIMER_CLO); +} + +uint32_t benchmark_timer_read(void) +{ + uint32_t delta = BCM2835_REG(BCM2835_GPU_TIMER_CLO) - benchmark_timer_base; + + if (benchmark_timer_find_average_overhead) + { + return delta; + } + else + { + return BCM2835_REG(BCM2835_GPU_TIMER_CLO); + } +} + +void benchmark_timer_disable_subtracting_average_overhead(bool find_average_overhead) +{ + benchmark_timer_find_average_overhead = find_average_overhead; +} |