mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
imx233: preventive fix of timrot
The old could trigger an immediate IRQ if for example the count was 0 when setting up the timer: since the count was updared *after* clearing the IRQ, it could fire in between. Change-Id: I0357b201655bc0e56425ffb249ca807525f30217
This commit is contained in:
parent
619f7fba93
commit
34fb6906dd
1 changed files with 10 additions and 5 deletions
|
|
@ -45,12 +45,17 @@ void imx233_timrot_setup(unsigned timer_nr, bool reload, unsigned count,
|
||||||
bool irq = fn != NULL;
|
bool irq = fn != NULL;
|
||||||
timer_fns[timer_nr] = fn;
|
timer_fns[timer_nr] = fn;
|
||||||
|
|
||||||
/* manual says count - 1 for reload timers */
|
/* make sure we start from stop state */
|
||||||
HW_TIMROT_TIMCTRLn(timer_nr) = BF_OR7(TIMROT_TIMCTRLn, SELECT(src),
|
HW_TIMROT_TIMCTRLn(timer_nr) = BF_OR2(TIMROT_TIMCTRLn,
|
||||||
PRESCALE(prescale), POLARITY(polarity), RELOAD(reload), IRQ(irq),
|
SELECT(BV_TIMROT_TIMCTRLn_SELECT__NEVER_TICK), UPDATE(1));
|
||||||
IRQ_EN(irq), UPDATE(1));
|
/* write count and take effect immediately with UPDATE
|
||||||
imx233_icoll_enable_interrupt(INT_SRC_TIMER(timer_nr), irq);
|
* manual says count-1 for reload timers */
|
||||||
HW_TIMROT_TIMCOUNTn(timer_nr) = reload ? count - 1 : count;
|
HW_TIMROT_TIMCOUNTn(timer_nr) = reload ? count - 1 : count;
|
||||||
|
/* start timer */
|
||||||
|
HW_TIMROT_TIMCTRLn(timer_nr) = BF_OR6(TIMROT_TIMCTRLn, SELECT(src),
|
||||||
|
PRESCALE(prescale), POLARITY(polarity), RELOAD(reload), IRQ(irq),
|
||||||
|
IRQ_EN(irq));
|
||||||
|
imx233_icoll_enable_interrupt(INT_SRC_TIMER(timer_nr), irq);
|
||||||
|
|
||||||
restore_interrupt(oldstatus);
|
restore_interrupt(oldstatus);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue