diff options
author | Joel Challis <git@zvecr.com> | 2020-04-02 22:23:57 +0100 |
---|---|---|
committer | Florian Didron <fdidron@users.noreply.github.com> | 2020-06-12 17:00:27 +0900 |
commit | fec6ee365cac76f3dbb9e81bd544eefe8f6dbc76 (patch) | |
tree | d4da10608dce4b2b312b92e5c774c8cab6fb8eae | |
parent | 65de39bb6d234a5527a3491f281b4a715de3e52b (diff) |
Initial support for ATtiny85 (#8632)
* Initial support for ATtiny85
* Update mcu selection
-rw-r--r-- | quantum/config_common.h | 3 | ||||
-rw-r--r-- | quantum/mcu_selection.mk | 15 | ||||
-rw-r--r-- | tmk_core/common/avr/bootloader.c | 10 | ||||
-rw-r--r-- | tmk_core/common/avr/timer.c | 19 |
4 files changed, 36 insertions, 11 deletions
diff --git a/quantum/config_common.h b/quantum/config_common.h index b3abdee774..1ad9bfe0da 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h @@ -64,6 +64,9 @@ # define PINB_ADDRESS 0x3 # define PINC_ADDRESS 0x6 # define PIND_ADDRESS 0x9 +# elif defined(__AVR_ATtiny85__) +# define ADDRESS_BASE 0x10 +# define PINB_ADDRESS 0x6 # else # error "Pins are not defined" # endif diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk index e3b4c3f7e3..2fc3a8f4c0 100644 --- a/quantum/mcu_selection.mk +++ b/quantum/mcu_selection.mk @@ -290,3 +290,18 @@ ifneq (,$(filter $(MCU),atmega328p)) NO_UART ?= yes NO_SUSPEND_POWER_DOWN ?= yes endif + +ifneq (,$(filter $(MCU),attiny85)) + PROTOCOL = VUSB + + # Processor frequency. + # This will define a symbol, F_CPU, in all source code files equal to the + # processor frequency in Hz. You can then use this symbol in your source code to + # calculate timings. Do NOT tack on a 'UL' at the end, this will be done + # automatically to create a 32-bit value in your source code. + F_CPU ?= 16500000 + + # unsupported features for now + NO_UART ?= yes + NO_SUSPEND_POWER_DOWN ?= yes +endif diff --git a/tmk_core/common/avr/bootloader.c b/tmk_core/common/avr/bootloader.c index ca9746f327..7e5d2b0579 100644 --- a/tmk_core/common/avr/bootloader.c +++ b/tmk_core/common/avr/bootloader.c @@ -237,17 +237,17 @@ void bootloader_jump(void) { "bootloader_startup_loop%=: \n\t" "rjmp bootloader_startup_loop%= \n\t" : - : [ mcucsrio ] "I"(_SFR_IO_ADDR(MCUCSR)), + : [mcucsrio] "I"(_SFR_IO_ADDR(MCUCSR)), # if (FLASHEND > 131071) - [ ramendhi ] "M"(((RAMEND - 2) >> 8) & 0xff), [ ramendlo ] "M"(((RAMEND - 2) >> 0) & 0xff), [ bootaddrhi ] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 16) & 0xff), + [ramendhi] "M"(((RAMEND - 2) >> 8) & 0xff), [ramendlo] "M"(((RAMEND - 2) >> 0) & 0xff), [bootaddrhi] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 16) & 0xff), # else - [ ramendhi ] "M"(((RAMEND - 1) >> 8) & 0xff), [ ramendlo ] "M"(((RAMEND - 1) >> 0) & 0xff), + [ramendhi] "M"(((RAMEND - 1) >> 8) & 0xff), [ramendlo] "M"(((RAMEND - 1) >> 0) & 0xff), # endif - [ bootaddrme ] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 8) & 0xff), [ bootaddrlo ] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 0) & 0xff)); + [bootaddrme] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 8) & 0xff), [bootaddrlo] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 0) & 0xff)); #else // Assume remaining boards are DFU, even if the flag isn't set -# if !(defined(__AVR_ATmega32A__) || defined(__AVR_ATmega328P__)) // no USB - maybe BOOTLOADER_BOOTLOADHID instead though? +# if !(defined(__AVR_ATmega32A__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATtiny85__)) // no USB - maybe BOOTLOADER_BOOTLOADHID instead though? UDCON = 1; USBCON = (1 << FRZCLK); // disable USB UCSR1B = 0; diff --git a/tmk_core/common/avr/timer.c b/tmk_core/common/avr/timer.c index 88fa1dfa65..c2e6c6e081 100644 --- a/tmk_core/common/avr/timer.c +++ b/tmk_core/common/avr/timer.c @@ -45,19 +45,26 @@ void timer_init(void) { # error "Timer prescaler value is not valid" #endif -#ifndef __AVR_ATmega32A__ +#if defined(__AVR_ATmega32A__) + // Timer0 CTC mode + TCCR0 = _BV(WGM01) | prescaler; + + OCR0 = TIMER_RAW_TOP; + TIMSK = _BV(OCIE0); +#elif defined(__AVR_ATtiny85__) // Timer0 CTC mode TCCR0A = _BV(WGM01); TCCR0B = prescaler; - OCR0A = TIMER_RAW_TOP; - TIMSK0 = _BV(OCIE0A); + OCR0A = TIMER_RAW_TOP; + TIMSK = _BV(OCIE0A); #else // Timer0 CTC mode - TCCR0 = _BV(WGM01) | prescaler; + TCCR0A = _BV(WGM01); + TCCR0B = prescaler; - OCR0 = TIMER_RAW_TOP; - TIMSK = _BV(OCIE0); + OCR0A = TIMER_RAW_TOP; + TIMSK0 = _BV(OCIE0A); #endif } |