aboutsummaryrefslogtreecommitdiff
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
parentf2901375ce9fbf14e4a95eabf3b6abc7bfbc4300 (diff)
downloadqmk_firmware-9c4bf0ac4aed4ab315f27bfa5d2f54b0dd931138.tar.gz
qmk_firmware-9c4bf0ac4aed4ab315f27bfa5d2f54b0dd931138.zip
Initial support for ATtiny85 (#8632)
* Initial support for ATtiny85 * Update mcu selection
-rw-r--r--quantum/config_common.h3
-rw-r--r--quantum/mcu_selection.mk15
-rw-r--r--tmk_core/common/avr/bootloader.c2
-rw-r--r--tmk_core/common/avr/timer.c19
4 files changed, 32 insertions, 7 deletions
diff --git a/quantum/config_common.h b/quantum/config_common.h
index 4cfd74b0f..9861c8678 100644
--- a/quantum/config_common.h
+++ b/quantum/config_common.h
@@ -63,6 +63,9 @@
63# define PINB_ADDRESS 0x3 63# define PINB_ADDRESS 0x3
64# define PINC_ADDRESS 0x6 64# define PINC_ADDRESS 0x6
65# define PIND_ADDRESS 0x9 65# define PIND_ADDRESS 0x9
66# elif defined(__AVR_ATtiny85__)
67# define ADDRESS_BASE 0x10
68# define PINB_ADDRESS 0x6
66# else 69# else
67# error "Pins are not defined" 70# error "Pins are not defined"
68# endif 71# endif
diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk
index ef7e8ae75..33de162bb 100644
--- a/quantum/mcu_selection.mk
+++ b/quantum/mcu_selection.mk
@@ -287,3 +287,18 @@ ifneq (,$(filter $(MCU),atmega328p))
287 NO_UART ?= yes 287 NO_UART ?= yes
288 NO_SUSPEND_POWER_DOWN ?= yes 288 NO_SUSPEND_POWER_DOWN ?= yes
289endif 289endif
290
291ifneq (,$(filter $(MCU),attiny85))
292 PROTOCOL = VUSB
293
294 # Processor frequency.
295 # This will define a symbol, F_CPU, in all source code files equal to the
296 # processor frequency in Hz. You can then use this symbol in your source code to
297 # calculate timings. Do NOT tack on a 'UL' at the end, this will be done
298 # automatically to create a 32-bit value in your source code.
299 F_CPU ?= 16500000
300
301 # unsupported features for now
302 NO_UART ?= yes
303 NO_SUSPEND_POWER_DOWN ?= yes
304endif
diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c
index ca9746f32..32f69ae8b 100644
--- a/tmk_core/common/avr/bootloader.c
+++ b/tmk_core/common/avr/bootloader.c
@@ -247,7 +247,7 @@ void bootloader_jump(void) {
247 247
248#else // Assume remaining boards are DFU, even if the flag isn't set 248#else // Assume remaining boards are DFU, even if the flag isn't set
249 249
250# if !(defined(__AVR_ATmega32A__) || defined(__AVR_ATmega328P__)) // no USB - maybe BOOTLOADER_BOOTLOADHID instead though? 250# if !(defined(__AVR_ATmega32A__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATtiny85__)) // no USB - maybe BOOTLOADER_BOOTLOADHID instead though?
251 UDCON = 1; 251 UDCON = 1;
252 USBCON = (1 << FRZCLK); // disable USB 252 USBCON = (1 << FRZCLK); // disable USB
253 UCSR1B = 0; 253 UCSR1B = 0;
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