Add support for soft serial to ATmega32U2 (#10204)

* Add support for soft serial to ATmega32U2

* Update drivers/avr/serial.c

* Update drivers/avr/serial.c

* Update drivers/avr/serial.c

* Fix comment

* Update drivers/avr/serial.c
This commit is contained in:
Naoto Takai 2020-09-03 01:18:21 +09:00 committed by James Young
parent 53ad78b4b6
commit 73d20754bb
No known key found for this signature in database
GPG Key ID: 8E1085BF6FCFBD74
3 changed files with 12 additions and 7 deletions

View File

@ -443,9 +443,11 @@ ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
# Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called. # Functions added via QUANTUM_LIB_SRC are only included in the final binary if they're called.
# Unused functions are pruned away, which is why we can add multiple drivers here without bloat. # Unused functions are pruned away, which is why we can add multiple drivers here without bloat.
ifeq ($(PLATFORM),AVR) ifeq ($(PLATFORM),AVR)
ifneq ($(NO_I2C),yes)
QUANTUM_LIB_SRC += i2c_master.c \ QUANTUM_LIB_SRC += i2c_master.c \
i2c_slave.c i2c_slave.c
endif endif
endif
SERIAL_DRIVER ?= bitbang SERIAL_DRIVER ?= bitbang
ifeq ($(strip $(SERIAL_DRIVER)), bitbang) ifeq ($(strip $(SERIAL_DRIVER)), bitbang)

View File

@ -20,11 +20,11 @@
#ifdef SOFT_SERIAL_PIN #ifdef SOFT_SERIAL_PIN
# ifdef __AVR_ATmega32U4__ # if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
// if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial. // if using ATmegaxxU4 I2C, can not use PD0 and PD1 in soft serial.
# ifdef USE_AVR_I2C # ifdef USE_AVR_I2C
# if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1 # if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1
# error Using ATmega32U4 I2C, so can not use PD0, PD1 # error Using ATmegaxxU4 I2C, so can not use PD0, PD1
# endif # endif
# endif # endif
@ -52,7 +52,7 @@
# define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31))) # define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31)))
# define SERIAL_PIN_INTERRUPT INT3_vect # define SERIAL_PIN_INTERRUPT INT3_vect
# endif # endif
# elif SOFT_SERIAL_PIN == E6 # elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) && SOFT_SERIAL_PIN == E6
# define EIMSK_BIT _BV(INT6) # define EIMSK_BIT _BV(INT6)
# define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61))) # define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61)))
# define SERIAL_PIN_INTERRUPT INT6_vect # define SERIAL_PIN_INTERRUPT INT6_vect
@ -61,7 +61,7 @@
# endif # endif
# else # else
# error serial.c now support ATmega32U4 only # error serial.c currently only supports ATmegaxxU2 and ATmegaxxU4
# endif # endif
# define ALWAYS_INLINE __attribute__((always_inline)) # define ALWAYS_INLINE __attribute__((always_inline))

View File

@ -318,6 +318,9 @@ ifneq (,$(filter $(MCU),atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 a
ifeq (,$(filter $(NO_INTERRUPT_CONTROL_ENDPOINT),yes)) ifeq (,$(filter $(NO_INTERRUPT_CONTROL_ENDPOINT),yes))
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
endif endif
ifneq (,$(filter $(MCU),atmega16u2 atmega32u2))
NO_I2C = yes
endif
endif endif
ifneq (,$(filter $(MCU),atmega32a)) ifneq (,$(filter $(MCU),atmega32a))