Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for soft serial to ATmega32U2 #10204

Merged
merged 6 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,10 @@ ifeq ($(strip $(SPLIT_KEYBOARD)), yes)
# 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.
ifeq ($(PLATFORM),AVR)
QUANTUM_LIB_SRC += i2c_master.c \
i2c_slave.c
ifneq ($(NO_I2C),yes)
QUANTUM_LIB_SRC += i2c_master.c \
i2c_slave.c
endif
endif

SERIAL_DRIVER ?= bitbang
Expand Down
10 changes: 5 additions & 5 deletions drivers/avr/serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

#ifdef SOFT_SERIAL_PIN

# ifdef __AVR_ATmega32U4__
// if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial.
# if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
// if using ATmegaxxU4 I2C, can not use PD0 and PD1 in soft serial.
# ifdef USE_AVR_I2C
# if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1
takai marked this conversation as resolved.
Show resolved Hide resolved
# error Using ATmega32U4 I2C, so can not use PD0, PD1
# error Using ATmegaxxU4 I2C, so can not use PD0, PD1
# endif
# endif

Expand Down Expand Up @@ -52,7 +52,7 @@
# define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31)))
# define SERIAL_PIN_INTERRUPT INT3_vect
# endif
# elif SOFT_SERIAL_PIN == E6
# elif defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) && SOFT_SERIAL_PIN == E6
takai marked this conversation as resolved.
Show resolved Hide resolved
# define EIMSK_BIT _BV(INT6)
# define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61)))
# define SERIAL_PIN_INTERRUPT INT6_vect
Expand All @@ -61,7 +61,7 @@
# endif

# else
# error serial.c now support ATmega32U4 only
# error serial.c currently only supports ATmegaxxU2 and ATmegaxxU4
# endif

# define ALWAYS_INLINE __attribute__((always_inline))
Expand Down
3 changes: 3 additions & 0 deletions quantum/mcu_selection.mk
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@ ifneq (,$(filter $(MCU),atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 a
ifeq (,$(filter $(NO_INTERRUPT_CONTROL_ENDPOINT),yes))
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
endif
ifneq (,$(filter $(MCU),atmega16u2 atmega32u2))
NO_I2C = yes
endif
endif

ifneq (,$(filter $(MCU),atmega32a))
Expand Down