From d92ffd1157e3ecc4ae2dbf8548c45c8b0269f664 Mon Sep 17 00:00:00 2001 From: Dasky <32983009+daskygit@users.noreply.github.com> Date: Sat, 30 Jan 2021 03:53:56 +0000 Subject: [PATCH] Adds AT90USB162 support (#11570) * at90usb162 support * fix missing bracket * Apply suggestions from code review Co-authored-by: Ryan Co-authored-by: Ryan --- bootloader.mk | 6 +++--- common_features.mk | 2 +- data/schemas/keyboard.jsonschema | 2 +- docs/compatible_microcontrollers.md | 1 + docs/feature_backlight.md | 24 ++++++++++----------- docs/ja/compatible_microcontrollers.md | 1 + docs/spi_driver.md | 12 +++++------ drivers/avr/serial.c | 6 +++--- drivers/avr/spi_master.c | 2 +- drivers/avr/spi_master.h | 2 +- drivers/avr/uart.c | 2 +- lib/python/qmk/constants.py | 2 +- lib/python/qmk/os_helpers/linux/__init__.py | 1 + quantum/backlight/backlight_avr.c | 2 +- quantum/config_common.h | 2 +- quantum/dynamic_keymap.c | 2 ++ quantum/mcu_selection.mk | 4 ++-- util/drivers.txt | 1 + util/udev/50-qmk.rules | 2 ++ 19 files changed, 42 insertions(+), 34 deletions(-) diff --git a/bootloader.mk b/bootloader.mk index 8b4bc7a0fc4..fd76446e99e 100644 --- a/bootloader.mk +++ b/bootloader.mk @@ -40,7 +40,7 @@ ifeq ($(strip $(BOOTLOADER)), atmel-dfu) OPT_DEFS += -DBOOTLOADER_ATMEL_DFU OPT_DEFS += -DBOOTLOADER_DFU - ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647)) + ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647)) BOOTLOADER_SIZE = 4096 endif ifneq (,$(filter $(MCU), at90usb1286 at90usb1287)) @@ -50,7 +50,7 @@ endif ifeq ($(strip $(BOOTLOADER)), lufa-dfu) OPT_DEFS += -DBOOTLOADER_LUFA_DFU OPT_DEFS += -DBOOTLOADER_DFU - ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647)) + ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647)) BOOTLOADER_SIZE = 4096 endif ifneq (,$(filter $(MCU), at90usb1286 at90usb1287)) @@ -60,7 +60,7 @@ endif ifeq ($(strip $(BOOTLOADER)), qmk-dfu) OPT_DEFS += -DBOOTLOADER_QMK_DFU OPT_DEFS += -DBOOTLOADER_DFU - ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647)) + ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647)) BOOTLOADER_SIZE = 4096 endif ifneq (,$(filter $(MCU), at90usb1286 at90usb1287)) diff --git a/common_features.mk b/common_features.mk index fa92a8482f0..6ed7e73b668 100644 --- a/common_features.mk +++ b/common_features.mk @@ -222,7 +222,7 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) $(error "$(RGB_MATRIX_DRIVER)" is not a valid matrix type) endif OPT_DEFS += -DRGB_MATRIX_ENABLE -ifneq (,$(filter $(MCU), atmega16u2 atmega32u2)) +ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162)) # ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines OPT_DEFS += -DLIB8_ATTINY endif diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 3dba21bc0f9..8f1c0a91578 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -25,7 +25,7 @@ }, "processor": { "type": "string", - "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F411", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"] + "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F411", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"] }, "board": { "type": "string", diff --git a/docs/compatible_microcontrollers.md b/docs/compatible_microcontrollers.md index ac90ed7464f..8694beb7cb7 100644 --- a/docs/compatible_microcontrollers.md +++ b/docs/compatible_microcontrollers.md @@ -9,6 +9,7 @@ The following use [LUFA](https://www.fourwalledcubicle.com/LUFA.php) as the USB * [ATmega16U2](https://www.microchip.com/wwwproducts/en/ATmega16U2) / [ATmega32U2](https://www.microchip.com/wwwproducts/en/ATmega32U2) * [ATmega16U4](https://www.microchip.com/wwwproducts/en/ATmega16U4) / [ATmega32U4](https://www.microchip.com/wwwproducts/en/ATmega32U4) * [AT90USB64](https://www.microchip.com/wwwproducts/en/AT90USB646) / [AT90USB128](https://www.microchip.com/wwwproducts/en/AT90USB1286) +* [AT90USB162](https://www.microchip.com/wwwproducts/en/AT90USB162) Certain MCUs which do not have native USB will use [V-USB](https://www.obdev.at/products/vusb/index.html) instead: diff --git a/docs/feature_backlight.md b/docs/feature_backlight.md index a558af64e14..2adb16e4a86 100644 --- a/docs/feature_backlight.md +++ b/docs/feature_backlight.md @@ -93,18 +93,18 @@ BACKLIGHT_DRIVER = pwm On AVR boards, QMK automatically decides which driver to use according to the following table: -|Backlight Pin|AT90USB64/128|ATmega16/32U4|ATmega16/32U2|ATmega32A|ATmega328/P| -|-------------|-------------|-------------|-------------|---------|-----------| -|`B1` | | | | |Timer 1 | -|`B2` | | | | |Timer 1 | -|`B5` |Timer 1 |Timer 1 | | | | -|`B6` |Timer 1 |Timer 1 | | | | -|`B7` |Timer 1 |Timer 1 |Timer 1 | | | -|`C4` |Timer 3 | | | | | -|`C5` |Timer 3 | |Timer 1 | | | -|`C6` |Timer 3 |Timer 3 |Timer 1 | | | -|`D4` | | | |Timer 1 | | -|`D5` | | | |Timer 1 | | +|Backlight Pin|AT90USB64/128|AT90USB162|ATmega16/32U4|ATmega16/32U2|ATmega32A|ATmega328/P| +|-------------|-------------|----------|-------------|-------------|---------|-----------| +|`B1` | | | | | |Timer 1 | +|`B2` | | | | | |Timer 1 | +|`B5` |Timer 1 | |Timer 1 | | | | +|`B6` |Timer 1 | |Timer 1 | | | | +|`B7` |Timer 1 |Timer 1 |Timer 1 |Timer 1 | | | +|`C4` |Timer 3 | | | | | | +|`C5` |Timer 3 |Timer 1 | |Timer 1 | | | +|`C6` |Timer 3 |Timer 1 |Timer 3 |Timer 1 | | | +|`D4` | | | | |Timer 1 | | +|`D5` | | | | |Timer 1 | | All other pins will use timer-assisted software PWM: diff --git a/docs/ja/compatible_microcontrollers.md b/docs/ja/compatible_microcontrollers.md index 56f4c029771..b89dd54b06d 100644 --- a/docs/ja/compatible_microcontrollers.md +++ b/docs/ja/compatible_microcontrollers.md @@ -14,6 +14,7 @@ QMK は十分な容量のフラッシュメモリを備えた USB 対応 AVR ま * [ATmega16U2](https://www.microchip.com/wwwproducts/en/ATmega16U2) / [ATmega32U2](https://www.microchip.com/wwwproducts/en/ATmega32U2) * [ATmega16U4](https://www.microchip.com/wwwproducts/en/ATmega16U4) / [ATmega32U4](https://www.microchip.com/wwwproducts/en/ATmega32U4) * [AT90USB64](https://www.microchip.com/wwwproducts/en/AT90USB646) / [AT90USB128](https://www.microchip.com/wwwproducts/en/AT90USB1286) +* [AT90USB162](https://www.microchip.com/wwwproducts/en/AT90USB162) 組み込みの USB インターフェースを持たない、いくつかの MCU は代わりに [V-USB](https://www.obdev.at/products/vusb/index.html) を使います: diff --git a/docs/spi_driver.md b/docs/spi_driver.md index 1d432432ad1..03c008da2ad 100644 --- a/docs/spi_driver.md +++ b/docs/spi_driver.md @@ -6,12 +6,12 @@ The SPI Master drivers used in QMK have a set of common functions to allow porta No special setup is required - just connect the `SS`, `SCK`, `MOSI` and `MISO` pins of your SPI devices to the matching pins on the MCU: -|MCU |`SS`|`SCK`|`MOSI`|`MISO`| -|---------------|----|-----|------|------| -|ATMega16/32U2/4|`B0`|`B1` |`B2` |`B3` | -|AT90USB64/128 |`B0`|`B1` |`B2` |`B3` | -|ATmega32A |`B4`|`B7` |`B5` |`B6` | -|ATmega328/P |`B2`|`B5` |`B3` |`B4` | +|MCU |`SS`|`SCK`|`MOSI`|`MISO`| +|-----------------|----|-----|------|------| +|ATMega16/32U2/4 |`B0`|`B1` |`B2` |`B3` | +|AT90USB64/128/162|`B0`|`B1` |`B2` |`B3` | +|ATmega32A |`B4`|`B7` |`B5` |`B6` | +|ATmega328/P |`B2`|`B5` |`B3` |`B4` | You may use more than one slave select pin, not just the `SS` pin. This is useful when you have multiple devices connected and need to communicate with them individually. `SPI_SS_PIN` can be passed to `spi_start()` to refer to `SS`. diff --git a/drivers/avr/serial.c b/drivers/avr/serial.c index 526a0946b26..3647bee0d35 100644 --- a/drivers/avr/serial.c +++ b/drivers/avr/serial.c @@ -20,7 +20,7 @@ #ifdef SOFT_SERIAL_PIN -# if !(defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) +# if !(defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) # error serial.c is not supported for the currently selected MCU # endif // if using ATmega32U4/2, AT90USBxxx I2C, can not use PD0 and PD1 in soft serial. @@ -52,8 +52,8 @@ # define EICRx EICRA # endif -// ATmegaxxU2 specific config -# if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) +// ATmegaxxU2/AT90USB162 specific config +# if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_AT90USB162__) // PD4(INT5), PD6(INT6), PD7(INT7), PC7(INT4) # if SOFT_SERIAL_PIN == D4 # define EIMSK_BIT _BV(INT5) diff --git a/drivers/avr/spi_master.c b/drivers/avr/spi_master.c index cbec9f36e1a..19ca0ced441 100644 --- a/drivers/avr/spi_master.c +++ b/drivers/avr/spi_master.c @@ -20,7 +20,7 @@ #include "quantum.h" #include "timer.h" -#if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) +#if defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) # define SPI_SCK_PIN B1 # define SPI_MOSI_PIN B2 # define SPI_MISO_PIN B3 diff --git a/drivers/avr/spi_master.h b/drivers/avr/spi_master.h index e36a7c21c06..9203698dd56 100644 --- a/drivers/avr/spi_master.h +++ b/drivers/avr/spi_master.h @@ -21,7 +21,7 @@ typedef int16_t spi_status_t; // Hardware SS pin is defined in the header so that user code can refer to it -#if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) +#if defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) # define SPI_SS_PIN B0 #elif defined(__AVR_ATmega32A__) # define SPI_SS_PIN B4 diff --git a/drivers/avr/uart.c b/drivers/avr/uart.c index e866a9e4f88..c6abcb6fe0d 100644 --- a/drivers/avr/uart.c +++ b/drivers/avr/uart.c @@ -29,7 +29,7 @@ #include "uart.h" -#if defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) +#if defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) # define UDRn UDR1 # define UBRRnL UBRR1L # define UCSRnA UCSR1A diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py index 404a58a7e5d..cb946135628 100644 --- a/lib/python/qmk/constants.py +++ b/lib/python/qmk/constants.py @@ -11,7 +11,7 @@ MAX_KEYBOARD_SUBFOLDERS = 5 # Supported processor types CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F411' -LUFA_PROCESSORS = 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None +LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85' # Common format strings diff --git a/lib/python/qmk/os_helpers/linux/__init__.py b/lib/python/qmk/os_helpers/linux/__init__.py index 86850bf2843..a04ac4f8a91 100644 --- a/lib/python/qmk/os_helpers/linux/__init__.py +++ b/lib/python/qmk/os_helpers/linux/__init__.py @@ -48,6 +48,7 @@ def check_udev_rules(): _udev_rule("03eb", "2ff3"), # ATmega16U4 _udev_rule("03eb", "2ff4"), # ATmega32U4 _udev_rule("03eb", "2ff9"), # AT90USB64 + _udev_rule("03eb", "2ffa"), # AT90USB162 _udev_rule("03eb", "2ffb") # AT90USB128 }, 'kiibohd': {_udev_rule("1c11", "b007")}, diff --git a/quantum/backlight/backlight_avr.c b/quantum/backlight/backlight_avr.c index 4d66da80ba1..2ecdd4f2c42 100644 --- a/quantum/backlight/backlight_avr.c +++ b/quantum/backlight/backlight_avr.c @@ -68,7 +68,7 @@ # define COMxx1 COM3A1 # define OCRxx OCR3A # endif -#elif (defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__)) && (BACKLIGHT_PIN == B7 || BACKLIGHT_PIN == C5 || BACKLIGHT_PIN == C6) +#elif (defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__)) && (BACKLIGHT_PIN == B7 || BACKLIGHT_PIN == C5 || BACKLIGHT_PIN == C6) # define HARDWARE_PWM # define ICRx ICR1 # define TCCRxA TCCR1A diff --git a/quantum/config_common.h b/quantum/config_common.h index 2d9c70b08de..df3a6c5c542 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h @@ -39,7 +39,7 @@ # define PIND_ADDRESS 0x9 # define PINE_ADDRESS 0xC # define PINF_ADDRESS 0xF -# elif defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) +# elif defined(__AVR_AT90USB162__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__) # define ADDRESS_BASE 0x00 # define PINB_ADDRESS 0x3 # define PINC_ADDRESS 0x6 diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index 0608b469c08..a860b949797 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -37,6 +37,8 @@ #ifndef DYNAMIC_KEYMAP_EEPROM_MAX_ADDR # if defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) # define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047 +# elif defined(__AVR_AT90USB162__) +# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 511 # else # define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 1023 # endif diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk index 6b11eb49872..09e07a37fd1 100644 --- a/quantum/mcu_selection.mk +++ b/quantum/mcu_selection.mk @@ -279,7 +279,7 @@ ifneq ($(findstring STM32F411, $(MCU)),) DFU_SUFFIX_ARGS ?= -v 0483 -p DF11 endif -ifneq (,$(filter $(MCU),atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647 at90usb1286 at90usb1287)) +ifneq (,$(filter $(MCU),at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647 at90usb1286 at90usb1287)) PROTOCOL = LUFA # Processor frequency. @@ -317,7 +317,7 @@ 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)) + ifneq (,$(filter $(MCU),at90usb162 atmega16u2 atmega32u2)) NO_I2C = yes endif endif diff --git a/util/drivers.txt b/util/drivers.txt index c3c5e286b1c..a41192571fe 100644 --- a/util/drivers.txt +++ b/util/drivers.txt @@ -11,4 +11,5 @@ libusb,ATmega32U2,03EB,2FF0,ddc2c572-cb6e-4f61-a6cc-1a5de941f063 libusb,ATmega16U4,03EB,2FF3,3180d426-bf93-4578-a693-2efbc337da8e libusb,ATmega32U4,03EB,2FF4,5f9726fd-f9de-487a-9fbd-8b3524a7a56a libusb,AT90USB64,03EB,2FF9,c6a708ad-e97d-43cd-b04a-3180d737a71b +libusb,AT90USB162,03EB,2FFA,ef8546f0-ef09-4e7c-8fc2-ffbae1dcd84a libusb,AT90USB128,03EB,2FFB,fd217df3-59d0-440a-a8f3-4c0c8c84daa3 diff --git a/util/udev/50-qmk.rules b/util/udev/50-qmk.rules index 70bd7e6e3e0..acaa7dcc587 100644 --- a/util/udev/50-qmk.rules +++ b/util/udev/50-qmk.rules @@ -9,6 +9,8 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff3", TAG+="uacc SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff4", TAG+="uaccess" ### AT90USB64 SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff9", TAG+="uaccess" +### AT90USB162 +SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ffa", TAG+="uaccess" ### AT90USB128 SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ffb", TAG+="uaccess"