summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2007-11-07 05:30:31 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2007-11-07 05:30:31 +0000
commit5db6b51759fa1b2e9595a177414874fc928d5180 (patch)
tree5cc59f4a3a9dd1499c233beaa714015618064f6e
parent22e3d5694030a919402a77c31178a60ce3839194 (diff)
downloadrockbox-5db6b51759fa1b2e9595a177414874fc928d5180.tar.gz
rockbox-5db6b51759fa1b2e9595a177414874fc928d5180.zip
Get the user timer working properly consequentially fixing doom without a hack.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15510 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/doom/i_system.c2
-rwxr-xr-xbootloader/mrobe500.c11
-rw-r--r--firmware/target/arm/tms320dm320/kernel-dm320.c2
-rw-r--r--firmware/target/arm/tms320dm320/system-dm320.c4
-rw-r--r--firmware/target/arm/tms320dm320/timer-dm320.c52
5 files changed, 34 insertions, 37 deletions
diff --git a/apps/plugins/doom/i_system.c b/apps/plugins/doom/i_system.c
index 95ea7a8f68..40ebe981b4 100644
--- a/apps/plugins/doom/i_system.c
+++ b/apps/plugins/doom/i_system.c
@@ -87,7 +87,7 @@ void doomtime(void)
87 87
88int I_GetTime (void) 88int I_GetTime (void)
89{ 89{
90#if defined(HAVE_LCD_COLOR) && !defined(TOSHIBA_GIGABEAT_F) && !defined(SIMULATOR) && !defined(RB_PROFILE) 90#if defined(HAVE_LCD_COLOR) && !defined(SIMULATOR) && !defined(RB_PROFILE)
91 return doomtimer; 91 return doomtimer;
92#else 92#else
93#if HZ==100 93#if HZ==100
diff --git a/bootloader/mrobe500.c b/bootloader/mrobe500.c
index 3663612c74..ede05aa25c 100755
--- a/bootloader/mrobe500.c
+++ b/bootloader/mrobe500.c
@@ -109,6 +109,7 @@ void mrdebug(void)
109 touchpad_calibrate_screen(); 109 touchpad_calibrate_screen();
110 use_calibration(true); 110 use_calibration(true);
111#endif 111#endif
112
112 while(true) 113 while(true)
113 { 114 {
114#if 0 115#if 0
@@ -144,14 +145,14 @@ void mrdebug(void)
144// tsc2100_read_values(&x, &y, &z1, &z2); 145// tsc2100_read_values(&x, &y, &z1, &z2);
145// printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2); 146// printf("x: %04x y: %04x z1: %04x z2: %04x", x, y, z1, z2);
146// printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff); 147// printf("tsadc: %4x", tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS)&0xffff);
147// printf("current tick: %04x", current_tick); 148 printf("current tick: %04x", current_tick);
148// printf("Address: 0x%08x Data: 0x%08x", address, *address); 149 printf("Address: 0x%08x Data: 0x%08x", address, *address);
149// printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1)); 150 printf("Address: 0x%08x Data: 0x%08x", address+1, *(address+1));
150// printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2)); 151 printf("Address: 0x%08x Data: 0x%08x", address+2, *(address+2));
151// // tsc2100_keyclick(); /* doesnt work :( */ 152// // tsc2100_keyclick(); /* doesnt work :( */
152// line -= 6; 153// line -= 6;
153// } 154// }
154#if 1 155#if 0
155 if (button&BUTTON_TOUCHPAD) 156 if (button&BUTTON_TOUCHPAD)
156 { 157 {
157 if (button&BUTTON_REL) 158 if (button&BUTTON_REL)
diff --git a/firmware/target/arm/tms320dm320/kernel-dm320.c b/firmware/target/arm/tms320dm320/kernel-dm320.c
index be2b14b3cb..6608aea096 100644
--- a/firmware/target/arm/tms320dm320/kernel-dm320.c
+++ b/firmware/target/arm/tms320dm320/kernel-dm320.c
@@ -32,7 +32,7 @@ void tick_start(unsigned int interval_in_ms)
32 /* Setup the Prescalar (Divide by 10) 32 /* Setup the Prescalar (Divide by 10)
33 * Based on linux/include/asm-arm/arch-integrator/timex.h 33 * Based on linux/include/asm-arm/arch-integrator/timex.h
34 */ 34 */
35 IO_TIMER1_TMPRSCL = 0x000A; 35 IO_TIMER1_TMPRSCL = 0x0009;
36 36
37 /* Setup the Divisor */ 37 /* Setup the Divisor */
38 IO_TIMER1_TMDIV = (TIMER_FREQ / (10*1000))*interval_in_ms; 38 IO_TIMER1_TMDIV = (TIMER_FREQ / (10*1000))*interval_in_ms;
diff --git a/firmware/target/arm/tms320dm320/system-dm320.c b/firmware/target/arm/tms320dm320/system-dm320.c
index c009766f21..da3b9913a2 100644
--- a/firmware/target/arm/tms320dm320/system-dm320.c
+++ b/firmware/target/arm/tms320dm320/system-dm320.c
@@ -169,6 +169,10 @@ void system_init(void)
169 169
170 IO_INTC_ENTRY_TBA0 = 0; 170 IO_INTC_ENTRY_TBA0 = 0;
171 IO_INTC_ENTRY_TBA1 = 0; 171 IO_INTC_ENTRY_TBA1 = 0;
172
173 /* Turn off other timers */
174 IO_TIMER2_TMMD = CONFIG_TIMER2_TMMD_STOP;
175 IO_TIMER3_TMMD = CONFIG_TIMER3_TMMD_STOP;
172 176
173 /* set GIO26 (reset pin) to output and low */ 177 /* set GIO26 (reset pin) to output and low */
174 IO_GIO_BITCLR1=(1<<10); 178 IO_GIO_BITCLR1=(1<<10);
diff --git a/firmware/target/arm/tms320dm320/timer-dm320.c b/firmware/target/arm/tms320dm320/timer-dm320.c
index 21449ed19f..482fef9f12 100644
--- a/firmware/target/arm/tms320dm320/timer-dm320.c
+++ b/firmware/target/arm/tms320dm320/timer-dm320.c
@@ -32,32 +32,16 @@ void TIMER0(void)
32 IO_INTC_IRQ0 |= 1<<IRQ_TIMER0; 32 IO_INTC_IRQ0 |= 1<<IRQ_TIMER0;
33} 33}
34 34
35static void stop_timer(void)
36{
37 IO_INTC_EINT0 &= ~(1<<IRQ_TIMER0);
38
39 IO_INTC_IRQ0 |= 1<<IRQ_TIMER0;
40
41 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP;
42}
43
44bool __timer_set(long cycles, bool start) 35bool __timer_set(long cycles, bool start)
45{ 36{
46 int oldlevel; 37 int oldlevel;
47 unsigned int divider; 38 unsigned int divider=cycles, prescaler=0;
48 /* taken from linux/arch/arm/mach-itdm320-20/time.c and timer-meg-fx.c */
49 39
50 /* Turn off all timers */ 40 if(cycles<1)
51 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP; 41 return false;
52 IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP;
53 IO_TIMER2_TMMD = CONFIG_TIMER2_TMMD_STOP;
54 IO_TIMER3_TMMD = CONFIG_TIMER3_TMMD_STOP;
55 42
56 /* Find the minimum factor that puts the counter in range 1-65535 */ 43 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP;
57 unsigned int prescaler = (cycles + 65534) / 65535;
58 44
59 /* Test this by writing 1's to registers to see how many bits we have */
60 /* Maximum divider setting is x / 1024 / 65536 = x / 67108864 */
61 if (start && pfn_unregister != NULL) 45 if (start && pfn_unregister != NULL)
62 { 46 {
63 pfn_unregister(); 47 pfn_unregister();
@@ -66,13 +50,14 @@ bool __timer_set(long cycles, bool start)
66 50
67 oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL); 51 oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
68 52
69 /* Max prescale is 1023+1 */ 53 /* Increase prescale values starting from 0 to make the cycle count fit */
70 for (divider = 0; prescaler > 1024; prescaler >>= 1, divider++); 54 while(divider>65535 && prescaler<1024)
55 {
56 prescaler++;
57 divider=cycles/(prescaler+1);
58 }
71 59
72 /* Setup the Prescalar */
73 IO_TIMER0_TMPRSCL = prescaler; 60 IO_TIMER0_TMPRSCL = prescaler;
74
75 /* Setup the Divisor */
76 IO_TIMER0_TMDIV = divider; 61 IO_TIMER0_TMDIV = divider;
77 62
78 set_irq_level(oldlevel); 63 set_irq_level(oldlevel);
@@ -80,22 +65,29 @@ bool __timer_set(long cycles, bool start)
80 return true; 65 return true;
81} 66}
82 67
83bool __timer_register(void) 68static void stop_timer(void)
84{ 69{
85 bool retval = true; 70 IO_INTC_EINT0 &= ~(1<<IRQ_TIMER0);
71
72 IO_INTC_IRQ0 |= 1<<IRQ_TIMER0;
73
74 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP;
75}
86 76
77bool __timer_register(void)
78{
87 int oldstatus = set_interrupt_status(IRQ_FIQ_DISABLED, IRQ_FIQ_STATUS); 79 int oldstatus = set_interrupt_status(IRQ_FIQ_DISABLED, IRQ_FIQ_STATUS);
88 80
89 stop_timer(); 81 stop_timer();
90 82
91 /* Turn Timer0 to Free Run mode */ 83 /* Turn Timer0 to Free Run mode */
92 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_FREE_RUN; 84 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_FREE_RUN;
93 85
94 IO_INTC_EINT0 |= 1<<IRQ_TIMER0; 86 IO_INTC_EINT0 |= 1<<IRQ_TIMER0;
95 87
96 set_interrupt_status(oldstatus, IRQ_FIQ_STATUS); 88 set_interrupt_status(oldstatus, IRQ_FIQ_STATUS);
97 89
98 return retval; 90 return true;
99} 91}
100 92
101void __timer_unregister(void) 93void __timer_unregister(void)