diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-04-20 12:08:42 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-04-20 13:52:19 +0200 |
commit | e0dd8a5ad830798bc8082b03b8c42c32fb9660e0 (patch) | |
tree | d147bfc4d670fcdfbd2e2d2e75eb209f92e07df1 /bsps/m32c | |
parent | bsps: Move startup files to bsps (diff) | |
download | rtems-e0dd8a5ad830798bc8082b03b8c42c32fb9660e0.tar.bz2 |
bsps: Move benchmark timer to bsps
This patch is a part of the BSP source reorganization.
Update #3285.
Diffstat (limited to 'bsps/m32c')
-rw-r--r-- | bsps/m32c/m32cbsp/btimer/btimer.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/bsps/m32c/m32cbsp/btimer/btimer.c b/bsps/m32c/m32cbsp/btimer/btimer.c new file mode 100644 index 0000000000..a27d9ffb1b --- /dev/null +++ b/bsps/m32c/m32cbsp/btimer/btimer.c @@ -0,0 +1,69 @@ +/* + * This file implements a stub benchmark timer that is sufficient to + * satisfy linking the RTEMS Benchmarks. + */ + +/* + * COPYRIGHT (c) 1989-2001. + * On-Line Applications Research Corporation (OAR). + */ + +#include <bsp.h> +#include <rtems/btimer.h> + +#include <varvects.h> + +bool benchmark_timer_find_average_overhead; +uint32_t benchmark_timer_overhead = 10; + +#define TABSR *((uint8_t *)0x340) +#define TA0MR *((uint8_t *)0x356) +#define TA0 *((uint16_t *)0x346) +#define TA0IC *((uint8_t *)0x6c) + +static int benchmark_timer_interrupts; + +static void __attribute__((interrupt)) timer_ra_interrupt(void); + +#define ivec_timer_a0 12 + +void __attribute__((interrupt)) +timer_ra_interrupt(void) +{ + benchmark_timer_interrupts++; + TA0IC = 0x05; + +} + +void benchmark_timer_initialize(void) +{ + benchmark_timer_interrupts = 0; + _set_var_vect (timer_ra_interrupt, ivec_timer_a0); + TA0MR = 0x00; + TA0 = 0xffff; + TA0IC = 0x05; + TABSR = 0x55; +} + +benchmark_timer_t benchmark_timer_read(void) +{ + uint32_t count; + + count = 0xFFFF - TA0; + count += benchmark_timer_interrupts * 0xFFFFL; + + if (!benchmark_timer_find_average_overhead) { + if ( count > benchmark_timer_overhead ) + count -= benchmark_timer_overhead; + else + count = 0; + } + return count; +} + +void benchmark_timer_disable_subtracting_average_overhead( + bool find_flag +) +{ + benchmark_timer_find_average_overhead = find_flag; +} |