diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-03-20 23:02:10 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-03-20 23:02:10 +0000 |
commit | fe064db965b91394f85a777608375ff782ab8c64 (patch) | |
tree | 81dce88da4c8b77466724dadc48aab3c77df0012 | |
parent | c7b6ad5fdf3e89b5c68e2448dc360c6838a3b241 (diff) | |
download | rockbox-fe064db965b91394f85a777608375ff782ab8c64.tar.gz rockbox-fe064db965b91394f85a777608375ff782ab8c64.zip |
Kill some yellow
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20416 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/timer-jz4740.c | 70 |
1 files changed, 67 insertions, 3 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/timer-jz4740.c b/firmware/target/mips/ingenic_jz47xx/timer-jz4740.c index 00c8abcdbd..dc02aede0e 100644 --- a/firmware/target/mips/ingenic_jz47xx/timer-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/timer-jz4740.c | |||
@@ -21,8 +21,72 @@ | |||
21 | 21 | ||
22 | #include "config.h" | 22 | #include "config.h" |
23 | #include "jz4740.h" | 23 | #include "jz4740.h" |
24 | #include "system.h" | ||
25 | #include "timer.h" | ||
24 | 26 | ||
27 | /* Interrupt handler */ | ||
28 | void TCU1(void) | ||
29 | { | ||
30 | __tcu_clear_full_match_flag(1); | ||
31 | |||
32 | if (pfn_timer != NULL) | ||
33 | pfn_timer(); | ||
34 | } | ||
25 | 35 | ||
26 | bool __timer_set(long cycles, bool set); | 36 | /* TODO: figure out what cycles means */ |
27 | bool __timer_register(void); | 37 | bool __timer_set(long cycles, bool start) |
28 | void __timer_unregister(void); | 38 | { |
39 | unsigned int latch, old_irq; | ||
40 | |||
41 | if(cycles < 1) | ||
42 | return false; | ||
43 | |||
44 | if (start && pfn_unregister != NULL) | ||
45 | { | ||
46 | pfn_unregister(); | ||
47 | pfn_unregister = NULL; | ||
48 | } | ||
49 | |||
50 | old_irq = disable_irq_save(); | ||
51 | |||
52 | __tcu_stop_counter(1); | ||
53 | __tcu_disable_pwm_output(1); | ||
54 | |||
55 | __tcu_mask_half_match_irq(1); | ||
56 | __tcu_unmask_full_match_irq(1); | ||
57 | |||
58 | /* EXTAL clock = 12Mhz */ | ||
59 | __tcu_select_extalclk(1); | ||
60 | /* 12Mhz / 4 = 3Mhz */ | ||
61 | __tcu_select_clk_div4(1); | ||
62 | |||
63 | latch = cycles; | ||
64 | |||
65 | REG_TCU_TCNT(1) = 0; | ||
66 | REG_TCU_TDFR(1) = latch; | ||
67 | REG_TCU_TDHR(1) = latch; | ||
68 | |||
69 | __tcu_clear_full_match_flag(1); | ||
70 | |||
71 | system_enable_irq(IRQ_TCU1); | ||
72 | |||
73 | restore_irq(old_irq); | ||
74 | } | ||
75 | |||
76 | bool __timer_register(void) | ||
77 | { | ||
78 | unsigned int old_irq = disable_irq_save(); | ||
79 | |||
80 | __tcu_start_counter(1); | ||
81 | |||
82 | restore_irq(old_irq); | ||
83 | } | ||
84 | |||
85 | void __timer_unregister(void) | ||
86 | { | ||
87 | unsigned int old_irq = disable_irq_save(); | ||
88 | |||
89 | __tcu_stop_counter(1); | ||
90 | |||
91 | restore_irq(old_irq); | ||
92 | } | ||