aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/common/avr/timer.c
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2020-04-02 22:23:57 +0100
committerGitHub <noreply@github.com>2020-04-02 22:23:57 +0100
commit9c4bf0ac4aed4ab315f27bfa5d2f54b0dd931138 (patch)
tree65e9caa97daa7616565835b0c0b88fe4ce79a8c4 /tmk_core/common/avr/timer.c
parentf2901375ce9fbf14e4a95eabf3b6abc7bfbc4300 (diff)
downloadqmk_firmware-9c4bf0ac4aed4ab315f27bfa5d2f54b0dd931138.tar.gz
qmk_firmware-9c4bf0ac4aed4ab315f27bfa5d2f54b0dd931138.zip
Initial support for ATtiny85 (#8632)
* Initial support for ATtiny85 * Update mcu selection
Diffstat (limited to 'tmk_core/common/avr/timer.c')
-rw-r--r--tmk_core/common/avr/timer.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/tmk_core/common/avr/timer.c b/tmk_core/common/avr/timer.c
index 88fa1dfa6..c2e6c6e08 100644
--- a/tmk_core/common/avr/timer.c
+++ b/tmk_core/common/avr/timer.c
@@ -45,19 +45,26 @@ void timer_init(void) {
45# error "Timer prescaler value is not valid" 45# error "Timer prescaler value is not valid"
46#endif 46#endif
47 47
48#ifndef __AVR_ATmega32A__ 48#if defined(__AVR_ATmega32A__)
49 // Timer0 CTC mode
50 TCCR0 = _BV(WGM01) | prescaler;
51
52 OCR0 = TIMER_RAW_TOP;
53 TIMSK = _BV(OCIE0);
54#elif defined(__AVR_ATtiny85__)
49 // Timer0 CTC mode 55 // Timer0 CTC mode
50 TCCR0A = _BV(WGM01); 56 TCCR0A = _BV(WGM01);
51 TCCR0B = prescaler; 57 TCCR0B = prescaler;
52 58
53 OCR0A = TIMER_RAW_TOP; 59 OCR0A = TIMER_RAW_TOP;
54 TIMSK0 = _BV(OCIE0A); 60 TIMSK = _BV(OCIE0A);
55#else 61#else
56 // Timer0 CTC mode 62 // Timer0 CTC mode
57 TCCR0 = _BV(WGM01) | prescaler; 63 TCCR0A = _BV(WGM01);
64 TCCR0B = prescaler;
58 65
59 OCR0 = TIMER_RAW_TOP; 66 OCR0A = TIMER_RAW_TOP;
60 TIMSK = _BV(OCIE0); 67 TIMSK0 = _BV(OCIE0A);
61#endif 68#endif
62} 69}
63 70