avr: Minor optimization for timer_read_time() / timer_periodic()

Tell the compiler that the TOV1 bit is rarely set.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2017-03-27 13:32:44 -04:00
parent 3238256b79
commit 31e78c90e2
1 changed files with 2 additions and 2 deletions

View File

@ -119,7 +119,7 @@ timer_read_time(void)
union u32_u calc;
calc.val = timer_get();
calc.hi = timer_high;
if (!(TIFR1 & (1<<TOV1))) {
if (likely(!(TIFR1 & (1<<TOV1)))) {
irq_restore(flag);
return calc.val;
}
@ -136,7 +136,7 @@ timer_read_time(void)
void
timer_periodic(void)
{
if (TIFR1 & (1<<TOV1)) {
if (unlikely(TIFR1 & (1<<TOV1))) {
// Hardware timer has overflowed - update overflow counter
TIFR1 = 1<<TOV1;
timer_high++;