ea25eb5e8f4bad1316fa03bc552c8ee394ba4acb
2 #include <hw/identifier.h>
6 unsigned int get_system_frequency(void)
8 return (CSR_IDENTIFIER_FREQ3
<< 24)
9 |(CSR_IDENTIFIER_FREQ2
<< 16)
10 |(CSR_IDENTIFIER_FREQ1
<< 8)
11 |CSR_IDENTIFIER_FREQ0
;
14 void timer_enable(int en
)
19 unsigned int timer_get(void)
21 return (CSR_TIMER0_COUNT3
<< 24)
22 |(CSR_TIMER0_COUNT2
<< 16)
23 |(CSR_TIMER0_COUNT1
<< 8)
27 void timer_set_counter(unsigned int value
)
29 CSR_TIMER0_COUNT3
= (value
& 0xff000000) >> 24;
30 CSR_TIMER0_COUNT2
= (value
& 0x00ff0000) >> 16;
31 CSR_TIMER0_COUNT1
= (value
& 0x0000ff00) >> 8;
32 CSR_TIMER0_COUNT0
= value
& 0x000000ff;
35 void timer_set_reload(unsigned int value
)
37 CSR_TIMER0_RELOAD3
= (value
& 0xff000000) >> 24;
38 CSR_TIMER0_RELOAD2
= (value
& 0x00ff0000) >> 16;
39 CSR_TIMER0_RELOAD1
= (value
& 0x0000ff00) >> 8;
40 CSR_TIMER0_RELOAD0
= value
& 0x000000ff;
43 void busy_wait(unsigned int ds
)
47 timer_set_counter(get_system_frequency()/10*ds
);