Timers: Don't hang when counter+target = 0 for timer1

This needs proper research into how it behaves with IRQs.
This commit is contained in:
Connor McLaughlin 2020-05-21 00:26:05 +10:00
parent 3c7229dfe2
commit 35a8c5b47c

View file

@ -96,7 +96,7 @@ TickCount Timers::GetTicksUntilIRQ(u32 timer) const
return std::numeric_limits<TickCount>::max();
TickCount ticks_until_irq = std::numeric_limits<TickCount>::max();
if (cs.mode.irq_at_target)
if (cs.mode.irq_at_target && cs.counter < cs.target)
ticks_until_irq = static_cast<TickCount>(cs.target - cs.counter);
if (cs.mode.irq_on_overflow)
ticks_until_irq = std::min(ticks_until_irq, static_cast<TickCount>(0xFFFFu - cs.counter));