Skip to content

Commit

Permalink
Initial support for ATtiny85 (qmk#8632)
Browse files Browse the repository at this point in the history
* Initial support for ATtiny85

* Update mcu selection
  • Loading branch information
zvecr authored Apr 2, 2020
1 parent f290137 commit 9c4bf0a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
3 changes: 3 additions & 0 deletions quantum/config_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,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
Expand Down
15 changes: 15 additions & 0 deletions quantum/mcu_selection.mk
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,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
2 changes: 1 addition & 1 deletion tmk_core/common/avr/bootloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ void bootloader_jump(void) {

#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;
Expand Down
19 changes: 13 additions & 6 deletions tmk_core/common/avr/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 9c4bf0a

Please sign in to comment.