diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-03-27 13:32:44 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-03-27 13:37:20 -0400 |
commit | 31e78c90e2f3c267779237e9cfaa3465e1571a87 (patch) | |
tree | 82ed4a67d2a9c9891ffd6af8fd7f2d772143881b /src/avr | |
parent | 3238256b79b3968bfa76e0c8b834231552221615 (diff) | |
download | kutter-31e78c90e2f3c267779237e9cfaa3465e1571a87.tar.gz kutter-31e78c90e2f3c267779237e9cfaa3465e1571a87.tar.xz kutter-31e78c90e2f3c267779237e9cfaa3465e1571a87.zip |
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>
Diffstat (limited to 'src/avr')
-rw-r--r-- | src/avr/timer.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/avr/timer.c b/src/avr/timer.c index 2de97526..c9c3ccca 100644 --- a/src/avr/timer.c +++ b/src/avr/timer.c @@ -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++; |