From b624f32f944acdc59dcb130674c09090c5c404cb Mon Sep 17 00:00:00 2001 From: skullY Date: Fri, 30 Aug 2019 11:19:03 -0700 Subject: clang-format changes --- tmk_core/common/avr/timer.c | 61 +++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 43 deletions(-) (limited to 'tmk_core/common/avr/timer.c') diff --git a/tmk_core/common/avr/timer.c b/tmk_core/common/avr/timer.c index b7d4f060ef..63ec549dff 100644 --- a/tmk_core/common/avr/timer.c +++ b/tmk_core/common/avr/timer.c @@ -22,7 +22,6 @@ along with this program. If not, see . #include "timer_avr.h" #include "timer.h" - // counter resolution 1ms // NOTE: union { uint32_t timer32; struct { uint16_t dummy; uint16_t timer16; }} volatile uint32_t timer_count; @@ -31,8 +30,7 @@ volatile uint32_t timer_count; * * FIXME: needs doc */ -void timer_init(void) -{ +void timer_init(void) { #if TIMER_PRESCALER == 1 uint8_t prescaler = 0x01; #elif TIMER_PRESCALER == 8 @@ -44,7 +42,7 @@ void timer_init(void) #elif TIMER_PRESCALER == 1024 uint8_t prescaler = 0x05; #else -# error "Timer prescaler value is NOT vaild." +# error "Timer prescaler value is NOT vaild." #endif #ifndef __AVR_ATmega32A__ @@ -53,13 +51,13 @@ void timer_init(void) TCCR0B = prescaler; - OCR0A = TIMER_RAW_TOP; - TIMSK0 = (1< Date: Sun, 8 Sep 2019 01:12:46 +1000 Subject: Banish some more magic numbers (#6662) --- tmk_core/common/avr/timer.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'tmk_core/common/avr/timer.c') diff --git a/tmk_core/common/avr/timer.c b/tmk_core/common/avr/timer.c index 63ec549dff..88fa1dfa65 100644 --- a/tmk_core/common/avr/timer.c +++ b/tmk_core/common/avr/timer.c @@ -32,33 +32,32 @@ volatile uint32_t timer_count; */ void timer_init(void) { #if TIMER_PRESCALER == 1 - uint8_t prescaler = 0x01; + uint8_t prescaler = _BV(CS00); #elif TIMER_PRESCALER == 8 - uint8_t prescaler = 0x02; + uint8_t prescaler = _BV(CS01); #elif TIMER_PRESCALER == 64 - uint8_t prescaler = 0x03; + uint8_t prescaler = _BV(CS00) | _BV(CS01); #elif TIMER_PRESCALER == 256 - uint8_t prescaler = 0x04; + uint8_t prescaler = _BV(CS02); #elif TIMER_PRESCALER == 1024 - uint8_t prescaler = 0x05; + uint8_t prescaler = _BV(CS00) | _BV(CS02); #else -# error "Timer prescaler value is NOT vaild." +# error "Timer prescaler value is not valid" #endif #ifndef __AVR_ATmega32A__ // Timer0 CTC mode - TCCR0A = 0x02; - + TCCR0A = _BV(WGM01); TCCR0B = prescaler; OCR0A = TIMER_RAW_TOP; - TIMSK0 = (1 << OCIE0A); + TIMSK0 = _BV(OCIE0A); #else // Timer0 CTC mode - TCCR0 = (1 << WGM01) | prescaler; + TCCR0 = _BV(WGM01) | prescaler; OCR0 = TIMER_RAW_TOP; - TIMSK = (1 << OCIE0); + TIMSK = _BV(OCIE0); #endif } -- cgit v1.2.3