File indexing completed on 2025-05-11 08:23:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #include <rtems.h>
0020 #include <rtems/btimer.h>
0021 #include <bsp.h>
0022
0023
0024 #define TICK_INTERVAL 0x10000U
0025 #define TIMER_INT_LEVEL 6
0026
0027 uint32_t Ttimer_val;
0028 bool benchmark_timer_find_average_overhead;
0029
0030 rtems_isr timerisr(rtems_vector_number vector);
0031
0032 void benchmark_timer_initialize(void)
0033 {
0034 (void) set_vector( timerisr, VBR0 * 0x10 + 0x8, 0 );
0035
0036 Ttimer_val = 0;
0037 lcsr->vector_base |= MASK_INT;
0038 lcsr->intr_clear |= 0x01000000;
0039 lcsr->to_ctl = 0xE7;
0040 lcsr->timer_cmp_1 = TICK_INTERVAL;
0041 lcsr->timer_cnt_1 = 0;
0042 lcsr->board_ctl |= 7;
0043
0044
0045 lcsr->intr_level[0] |= TIMER_INT_LEVEL;
0046 lcsr->intr_ena |= 0x01000000;
0047 }
0048
0049 #define AVG_OVERHEAD 3U
0050
0051 #define LEAST_VALID 10U
0052
0053 benchmark_timer_t benchmark_timer_read(void)
0054 {
0055 uint32_t total;
0056
0057 total = (Ttimer_val * TICK_INTERVAL) + lcsr->timer_cnt_1;
0058
0059 if ( benchmark_timer_find_average_overhead == true )
0060 return total;
0061
0062 if ( total < LEAST_VALID )
0063 return 0;
0064
0065 return (total-AVG_OVERHEAD) >> 1;
0066 }
0067
0068 void benchmark_timer_disable_subtracting_average_overhead(
0069 bool find_flag
0070 )
0071 {
0072 benchmark_timer_find_average_overhead = find_flag;
0073 }