From bb5fbf7c3092fe5847c1d730c88f0892c16ce5c6 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Mon, 28 Aug 2006 06:47:26 +0000 Subject: Fix broken backlight fading on ipod. The timer period setting must not be delayed if timer_set_period() is called from within the isr. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10779 a1c6a512-1295-4272-9138-f99709370657 --- firmware/timer.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'firmware/timer.c') diff --git a/firmware/timer.c b/firmware/timer.c index ab1a9ec..fd9bee2 100644 --- a/firmware/timer.c +++ b/firmware/timer.c @@ -59,7 +59,13 @@ void TIMER2(void) cycles_new = 0; } if (pfn_timer != NULL) + { + cycles_new = -1; + /* "lock" the variable, in case timer_set_period() + * is called within pfn_timer() */ pfn_timer(); + cycles_new = 0; + } } #endif /* CONFIG_CPU */ @@ -155,11 +161,9 @@ static bool timer_set(long cycles, bool start) pfn_unregister(); pfn_unregister = NULL; } - cycles_new = 0; - TIMER2_CFG = 0; - TIMER2_VAL; - TIMER2_CFG = 0xc0000000 | cycles; /* enable timer */ } + if (start || (cycles_new == -1)) /* within isr, cycles_new is "locked" */ + TIMER2_CFG = 0xc0000000 | cycles; /* enable timer */ else cycles_new = cycles; -- cgit v1.1