aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common/avr/timer.c
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common/avr/timer.c')
-rw-r--r--tmk_core/common/avr/timer.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/tmk_core/common/avr/timer.c b/tmk_core/common/avr/timer.c
index 63ec549df..88fa1dfa6 100644
--- a/tmk_core/common/avr/timer.c
+++ b/tmk_core/common/avr/timer.c
@@ -32,33 +32,32 @@ volatile uint32_t timer_count;
32 */ 32 */
33void timer_init(void) { 33void timer_init(void) {
34#if TIMER_PRESCALER == 1 34#if TIMER_PRESCALER == 1
35 uint8_t prescaler = 0x01; 35 uint8_t prescaler = _BV(CS00);
36#elif TIMER_PRESCALER == 8 36#elif TIMER_PRESCALER == 8
37 uint8_t prescaler = 0x02; 37 uint8_t prescaler = _BV(CS01);
38#elif TIMER_PRESCALER == 64 38#elif TIMER_PRESCALER == 64
39 uint8_t prescaler = 0x03; 39 uint8_t prescaler = _BV(CS00) | _BV(CS01);
40#elif TIMER_PRESCALER == 256 40#elif TIMER_PRESCALER == 256
41 uint8_t prescaler = 0x04; 41 uint8_t prescaler = _BV(CS02);
42#elif TIMER_PRESCALER == 1024 42#elif TIMER_PRESCALER == 1024
43 uint8_t prescaler = 0x05; 43 uint8_t prescaler = _BV(CS00) | _BV(CS02);
44#else 44#else
45# error "Timer prescaler value is NOT vaild." 45# error "Timer prescaler value is not valid"
46#endif 46#endif
47 47
48#ifndef __AVR_ATmega32A__ 48#ifndef __AVR_ATmega32A__
49 // Timer0 CTC mode 49 // Timer0 CTC mode
50 TCCR0A = 0x02; 50 TCCR0A = _BV(WGM01);
51
52 TCCR0B = prescaler; 51 TCCR0B = prescaler;
53 52
54 OCR0A = TIMER_RAW_TOP; 53 OCR0A = TIMER_RAW_TOP;
55 TIMSK0 = (1 << OCIE0A); 54 TIMSK0 = _BV(OCIE0A);
56#else 55#else
57 // Timer0 CTC mode 56 // Timer0 CTC mode
58 TCCR0 = (1 << WGM01) | prescaler; 57 TCCR0 = _BV(WGM01) | prescaler;
59 58
60 OCR0 = TIMER_RAW_TOP; 59 OCR0 = TIMER_RAW_TOP;
61 TIMSK = (1 << OCIE0); 60 TIMSK = _BV(OCIE0);
62#endif 61#endif
63} 62}
64 63