File indexing completed on 2025-05-11 08:23:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <bsp.h>
0015 #include <rtems.h>
0016 #include <rtems/btimer.h>
0017 #include <s3c24xx.h>
0018
0019 uint32_t g_start;
0020 uint32_t g_freq;
0021
0022 bool benchmark_timer_find_average_overhead;
0023
0024
0025
0026
0027
0028 void benchmark_timer_initialize( void )
0029 {
0030 uint32_t cr;
0031
0032
0033 cr=rTCON & 0xFFFFF0FF;
0034 rTCON=(cr | (0x0 << 8));
0035
0036
0037 cr=rTCFG1 & 0xFFFFFF0F;
0038 rTCFG1=(cr | (0<<4));
0039
0040
0041 g_freq = get_PCLK() / 2000;
0042 rTCNTB1 = 0xFFFF;
0043
0044
0045 cr=rTCON & 0xFFFFF0FF;
0046 rTCON=(cr | (0x1 << 9));
0047 rTCON=(cr | (0x1 << 8));
0048
0049 g_start = rTCNTO1;
0050 }
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 #define AVG_OVERHEAD 0
0063
0064
0065 #define LEAST_VALID 1
0066
0067 benchmark_timer_t benchmark_timer_read( void )
0068 {
0069 uint32_t t;
0070 unsigned long long total;
0071
0072 t = rTCNTO1;
0073
0074
0075
0076
0077
0078
0079 total = (g_start - t);
0080
0081
0082 total = (total*1000) / g_freq;
0083
0084 if ( benchmark_timer_find_average_overhead == 1 ) {
0085 return (int) total;
0086 } else if ( total < LEAST_VALID ) {
0087 return 0;
0088 }
0089
0090
0091
0092
0093 return (total - AVG_OVERHEAD);
0094 }
0095
0096 void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
0097 {
0098 benchmark_timer_find_average_overhead = find_flag;
0099 }
0100