diff options
31 files changed, 904 insertions, 126 deletions
diff --git a/bootloader.mk b/bootloader.mk index 5ba118fb4..ccb92392d 100644 --- a/bootloader.mk +++ b/bootloader.mk | |||
| @@ -34,6 +34,8 @@ | |||
| 34 | # stm32duino STM32Duino (STM32F103x8) | 34 | # stm32duino STM32Duino (STM32F103x8) |
| 35 | # stm32-dfu STM32 USB DFU in ROM | 35 | # stm32-dfu STM32 USB DFU in ROM |
| 36 | # apm32-dfu APM32 USB DFU in ROM | 36 | # apm32-dfu APM32 USB DFU in ROM |
| 37 | # RISC-V: | ||
| 38 | # gd32v-dfu GD32V USB DFU in ROM | ||
| 37 | # | 39 | # |
| 38 | # BOOTLOADER_SIZE can still be defined manually, but it's recommended | 40 | # BOOTLOADER_SIZE can still be defined manually, but it's recommended |
| 39 | # you add any possible configuration to this list | 41 | # you add any possible configuration to this list |
| @@ -125,6 +127,13 @@ ifeq ($(strip $(BOOTLOADER)), apm32-dfu) | |||
| 125 | DFU_ARGS ?= -d 314B:0106 -a 0 -s 0x08000000:leave | 127 | DFU_ARGS ?= -d 314B:0106 -a 0 -s 0x08000000:leave |
| 126 | DFU_SUFFIX_ARGS ?= -v 314B -p 0106 | 128 | DFU_SUFFIX_ARGS ?= -v 314B -p 0106 |
| 127 | endif | 129 | endif |
| 130 | ifeq ($(strip $(BOOTLOADER)), gd32v-dfu) | ||
| 131 | OPT_DEFS += -DBOOTLOADER_GD32V_DFU | ||
| 132 | |||
| 133 | # Options to pass to dfu-util when flashing | ||
| 134 | DFU_ARGS ?= -d 28E9:0189 -a 0 -s 0x08000000:leave | ||
| 135 | DFU_SUFFIX_ARGS ?= -v 28E9 -p 0189 | ||
| 136 | endif | ||
| 128 | ifeq ($(strip $(BOOTLOADER)), kiibohd) | 137 | ifeq ($(strip $(BOOTLOADER)), kiibohd) |
| 129 | OPT_DEFS += -DBOOTLOADER_KIIBOHD | 138 | OPT_DEFS += -DBOOTLOADER_KIIBOHD |
| 130 | ifeq ($(strip $(MCU_ORIG)), MK20DX128) | 139 | ifeq ($(strip $(MCU_ORIG)), MK20DX128) |
diff --git a/common_features.mk b/common_features.mk index aff91641e..7dd63be5b 100644 --- a/common_features.mk +++ b/common_features.mk | |||
| @@ -142,7 +142,7 @@ else | |||
| 142 | ifeq ($(PLATFORM),AVR) | 142 | ifeq ($(PLATFORM),AVR) |
| 143 | # Automatically provided by avr-libc, nothing required | 143 | # Automatically provided by avr-libc, nothing required |
| 144 | else ifeq ($(PLATFORM),CHIBIOS) | 144 | else ifeq ($(PLATFORM),CHIBIOS) |
| 145 | ifneq ($(filter STM32F3xx_% STM32F1xx_% %_STM32F401xC %_STM32F401xE %_STM32F405xG %_STM32F411xE %_STM32F072xB %_STM32F042x6, $(MCU_SERIES)_$(MCU_LDSCRIPT)),) | 145 | ifneq ($(filter STM32F3xx_% STM32F1xx_% %_STM32F401xC %_STM32F401xE %_STM32F405xG %_STM32F411xE %_STM32F072xB %_STM32F042x6 %_GD32VF103xB %_GD32VF103x8, $(MCU_SERIES)_$(MCU_LDSCRIPT)),) |
| 146 | OPT_DEFS += -DEEPROM_DRIVER | 146 | OPT_DEFS += -DEEPROM_DRIVER |
| 147 | COMMON_VPATH += $(DRIVER_PATH)/eeprom | 147 | COMMON_VPATH += $(DRIVER_PATH)/eeprom |
| 148 | SRC += eeprom_driver.c | 148 | SRC += eeprom_driver.c |
diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index b6b5e411f..65d44c94d 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | }, | 13 | }, |
| 14 | "processor": { | 14 | "processor": { |
| 15 | "type": "string", | 15 | "type": "string", |
| 16 | "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "MK66FX1M0", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F405", "STM32F407", "STM32F411", "STM32F446", "STM32G431", "STM32G474", "STM32L412", "STM32L422", "STM32L433", "STM32L443", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"] | 16 | "enum": ["cortex-m0", "cortex-m0plus", "cortex-m3", "cortex-m4", "MKL26Z64", "MK20DX128", "MK20DX256", "MK66FX1M0", "STM32F042", "STM32F072", "STM32F103", "STM32F303", "STM32F401", "STM32F405", "STM32F407", "STM32F411", "STM32F446", "STM32G431", "STM32G474", "STM32L412", "STM32L422", "STM32L433", "STM32L443", "GD32VF103", "atmega16u2", "atmega32u2", "atmega16u4", "atmega32u4", "at90usb162", "at90usb646", "at90usb647", "at90usb1286", "at90usb1287", "atmega32a", "atmega328p", "atmega328", "attiny85", "unknown"] |
| 17 | }, | 17 | }, |
| 18 | "audio": { | 18 | "audio": { |
| 19 | "type": "object", | 19 | "type": "object", |
| @@ -56,7 +56,7 @@ | |||
| 56 | }, | 56 | }, |
| 57 | "bootloader": { | 57 | "bootloader": { |
| 58 | "type": "string", | 58 | "type": "string", |
| 59 | "enum": ["atmel-dfu", "bootloadhid", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "unknown", "usbasploader", "USBasp", "tinyuf2"], | 59 | "enum": ["atmel-dfu", "bootloadhid", "bootloadHID", "caterina", "halfkay", "kiibohd", "lufa-dfu", "lufa-ms", "micronucleus", "qmk-dfu", "qmk-hid", "stm32-dfu", "stm32duino", "gd32v-dfu", "unknown", "usbasploader", "USBasp", "tinyuf2"], |
| 60 | }, | 60 | }, |
| 61 | "bootloader_instructions": { | 61 | "bootloader_instructions": { |
| 62 | "type": "string", | 62 | "type": "string", |
diff --git a/docs/compatible_microcontrollers.md b/docs/compatible_microcontrollers.md index f4aab5f5b..39e9061c2 100644 --- a/docs/compatible_microcontrollers.md +++ b/docs/compatible_microcontrollers.md | |||
| @@ -48,3 +48,9 @@ You can also use any ARM chip with USB that [ChibiOS](https://www.chibios.org) s | |||
| 48 | ## Atmel ATSAM | 48 | ## Atmel ATSAM |
| 49 | 49 | ||
| 50 | There is limited support for one of Atmel's ATSAM microcontrollers, that being the [ATSAMD51J18A](https://www.microchip.com/wwwproducts/en/ATSAMD51J18A) used by the [Massdrop keyboards](https://github.com/qmk/qmk_firmware/tree/master/keyboards/massdrop). | 50 | There is limited support for one of Atmel's ATSAM microcontrollers, that being the [ATSAMD51J18A](https://www.microchip.com/wwwproducts/en/ATSAMD51J18A) used by the [Massdrop keyboards](https://github.com/qmk/qmk_firmware/tree/master/keyboards/massdrop). |
| 51 | |||
| 52 | ## RISC-V | ||
| 53 | |||
| 54 | ### GigaDevice | ||
| 55 | |||
| 56 | [ChibiOS-Contrib](https://github.com/ChibiOS/ChibiOS-Contrib) has support for the GigaDevice [GD32VF103 series](https://www.gigadevice.com/products/microcontrollers/gd32/risc-v/mainstream-line/gd32vf103-series/) microcontrollers and provides configurations for the [SiPeed Longan Nano](https://longan.sipeed.com/en/) development board that uses this microcontroller. It is largely pin and feature compatible with STM32F103 and STM32F303 microcontrollers. \ No newline at end of file | ||
diff --git a/docs/driver_installation_zadig.md b/docs/driver_installation_zadig.md index 9155e56e3..003629ba9 100644 --- a/docs/driver_installation_zadig.md +++ b/docs/driver_installation_zadig.md | |||
| @@ -93,6 +93,7 @@ The device name here is the name that appears in Zadig, and may not be what the | |||
| 93 | |`usbasploader`|USBasp |`16C0:05DC` |libusbK| | 93 | |`usbasploader`|USBasp |`16C0:05DC` |libusbK| |
| 94 | |`apm32-dfu` |APM32 DFU ISP Mode |`314B:0106` |WinUSB | | 94 | |`apm32-dfu` |APM32 DFU ISP Mode |`314B:0106` |WinUSB | |
| 95 | |`stm32-dfu` |STM32 BOOTLOADER |`0483:DF11` |WinUSB | | 95 | |`stm32-dfu` |STM32 BOOTLOADER |`0483:DF11` |WinUSB | |
| 96 | |`gd32v-dfu` |GD32V BOOTLOADER |`28E9:0189` |WinUSB | | ||
| 96 | |`kiibohd` |Kiibohd DFU Bootloader |`1C11:B007` |WinUSB | | 97 | |`kiibohd` |Kiibohd DFU Bootloader |`1C11:B007` |WinUSB | |
| 97 | |`stm32duino` |Maple 003 |`1EAF:0003` |WinUSB | | 98 | |`stm32duino` |Maple 003 |`1EAF:0003` |WinUSB | |
| 98 | |`qmk-hid` |(keyboard name) Bootloader |`03EB:2067` |HidUsb | | 99 | |`qmk-hid` |(keyboard name) Bootloader |`03EB:2067` |HidUsb | |
diff --git a/drivers/led/apa102.c b/drivers/led/apa102.c index 19e0bfc18..00e7eb450 100644 --- a/drivers/led/apa102.c +++ b/drivers/led/apa102.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | # elif defined(PROTOCOL_CHIBIOS) | 24 | # elif defined(PROTOCOL_CHIBIOS) |
| 25 | 25 | ||
| 26 | # include "hal.h" | 26 | # include "hal.h" |
| 27 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) | 27 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) || defined(GD32VF103) |
| 28 | # define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4))) // This calculates how many loops of 4 nops to run to delay 100 ns | 28 | # define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4))) // This calculates how many loops of 4 nops to run to delay 100 ns |
| 29 | # else | 29 | # else |
| 30 | # error("APA102_NOPS configuration required") | 30 | # error("APA102_NOPS configuration required") |
diff --git a/keyboards/handwired/onekey/keymaps/quine/rules.mk b/keyboards/handwired/onekey/keymaps/quine/rules.mk deleted file mode 100644 index 4c2b0289a..000000000 --- a/keyboards/handwired/onekey/keymaps/quine/rules.mk +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | BOOTLOADER = atmel-dfu | ||
diff --git a/keyboards/handwired/onekey/readme.md b/keyboards/handwired/onekey/readme.md index b630b1174..2973b7d87 100644 --- a/keyboards/handwired/onekey/readme.md +++ b/keyboards/handwired/onekey/readme.md | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | Custom handwired one key keyboard. **See each individual board for pin information.** | 3 | Custom handwired one key keyboard. **See each individual board for pin information.** |
| 4 | 4 | ||
| 5 | * Keyboard Maintainer: QMK Community | 5 | * Keyboard Maintainer: QMK Community |
| 6 | * Hardware Supported: bluepill, Elite-C, Pro Micro, Proton C, Teensy 2.0, Teensy++ 2.0, Teensy LC, Teensy 3.2 | 6 | * Hardware Supported: Blackpill F401/F411, Bluepill, Elite-C, Pro Micro, Proton C, Sipeed Longan Nano, STM32F0 Disco, Teensy 2.0, Teensy++ 2.0, Teensy LC, Teensy 3.2 |
| 7 | * Hardware Availability: *n/a* | 7 | * Hardware Availability: *n/a* |
| 8 | 8 | ||
| 9 | Make example for this keyboard (after setting up your build environment): | 9 | Make example for this keyboard (after setting up your build environment): |
diff --git a/keyboards/handwired/onekey/sipeed_longan_nano/chconf.h b/keyboards/handwired/onekey/sipeed_longan_nano/chconf.h new file mode 100644 index 000000000..b1eb18de7 --- /dev/null +++ b/keyboards/handwired/onekey/sipeed_longan_nano/chconf.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | #define CH_CFG_ST_RESOLUTION 16 | ||
| 20 | |||
| 21 | #define CH_CFG_ST_FREQUENCY 10000 | ||
| 22 | |||
| 23 | #include_next <chconf.h> | ||
diff --git a/keyboards/handwired/onekey/sipeed_longan_nano/config.h b/keyboards/handwired/onekey/sipeed_longan_nano/config.h new file mode 100644 index 000000000..1825b936d --- /dev/null +++ b/keyboards/handwired/onekey/sipeed_longan_nano/config.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | #include "config_common.h" | ||
| 20 | |||
| 21 | #define MATRIX_COL_PINS \ | ||
| 22 | { B0 } | ||
| 23 | #define MATRIX_ROW_PINS \ | ||
| 24 | { A7 } | ||
| 25 | #define UNUSED_PINS | ||
| 26 | |||
| 27 | #define BACKLIGHT_PIN A1 /* Green LED. */ | ||
| 28 | #define BACKLIGHT_PWM_DRIVER PWMD5 /* GD32 numbering scheme starts from 0, TIMER4 on GD32 boards is TIMER5 on STM32 boards. */ | ||
| 29 | #define BACKLIGHT_PWM_CHANNEL 2 /* GD32 numbering scheme starts from 0, Channel 1 on GD32 boards is Channel 2 on STM32 boards. */ | ||
| 30 | |||
| 31 | #define RGB_DI_PIN A2 | ||
| 32 | #define RGB_CI_PIN B13 | ||
| 33 | |||
| 34 | #define ADC_PIN A0 | ||
| 35 | |||
| 36 | #define I2C1_CLOCK_SPEED 1000000 /* GD32VF103 supports fast mode plus. */ | ||
| 37 | #define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2 | ||
diff --git a/keyboards/handwired/onekey/sipeed_longan_nano/halconf.h b/keyboards/handwired/onekey/sipeed_longan_nano/halconf.h new file mode 100644 index 000000000..2579c5874 --- /dev/null +++ b/keyboards/handwired/onekey/sipeed_longan_nano/halconf.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | #define HAL_USE_PWM TRUE | ||
| 20 | #define HAL_USE_ADC TRUE | ||
| 21 | #define HAL_USE_I2C TRUE | ||
| 22 | |||
| 23 | #include_next <halconf.h> | ||
diff --git a/keyboards/handwired/onekey/sipeed_longan_nano/mcuconf.h b/keyboards/handwired/onekey/sipeed_longan_nano/mcuconf.h new file mode 100644 index 000000000..eba0dd9ee --- /dev/null +++ b/keyboards/handwired/onekey/sipeed_longan_nano/mcuconf.h | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | /* | ||
| 2 | ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio | ||
| 3 | ChibiOS - Copyright (C) 2021 Stefan Kerkmann | ||
| 4 | |||
| 5 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 6 | you may not use this file except in compliance with the License. | ||
| 7 | You may obtain a copy of the License at | ||
| 8 | |||
| 9 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 10 | |||
| 11 | Unless required by applicable law or agreed to in writing, software | ||
| 12 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 14 | See the License for the specific language governing permissions and | ||
| 15 | limitations under the License. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include_next <mcuconf.h> | ||
| 21 | |||
| 22 | #undef GD32_ADC_USE_ADC0 | ||
| 23 | #define GD32_ADC_USE_ADC0 TRUE | ||
| 24 | |||
| 25 | #undef GD32_I2C_USE_I2C0 | ||
| 26 | #define GD32_I2C_USE_I2C0 TRUE | ||
| 27 | |||
| 28 | #undef GD32_PWM_USE_TIM4 | ||
| 29 | #define GD32_PWM_USE_TIM4 TRUE | ||
diff --git a/keyboards/handwired/onekey/sipeed_longan_nano/readme.md b/keyboards/handwired/onekey/sipeed_longan_nano/readme.md new file mode 100644 index 000000000..0a3a29157 --- /dev/null +++ b/keyboards/handwired/onekey/sipeed_longan_nano/readme.md | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | # Sipeed Longan Nano onekey | ||
| 2 | |||
| 3 | Supported Hardware: *GD32VF103CB Sipeed Longan Nano*. | ||
| 4 | |||
| 5 | To trigger keypress, short together pins *B0* and *A7*. \ No newline at end of file | ||
diff --git a/keyboards/handwired/onekey/sipeed_longan_nano/rules.mk b/keyboards/handwired/onekey/sipeed_longan_nano/rules.mk new file mode 100644 index 000000000..aef4fee6b --- /dev/null +++ b/keyboards/handwired/onekey/sipeed_longan_nano/rules.mk | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | # MCU name | ||
| 2 | MCU = GD32VF103 | ||
| 3 | BOARD = SIPEED_LONGAN_NANO | ||
| 4 | |||
| 5 | # Bootloader selection | ||
| 6 | BOOTLOADER = gd32v-dfu | ||
| 7 | |||
| 8 | # Build Options | ||
| 9 | # change yes to no to disable | ||
| 10 | # | ||
| 11 | KEYBOARD_SHARED_EP = yes | ||
diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py index bfcd4064a..73f596ba2 100644 --- a/lib/python/qmk/constants.py +++ b/lib/python/qmk/constants.py | |||
| @@ -13,7 +13,7 @@ QMK_FIRMWARE_UPSTREAM = 'qmk/qmk_firmware' | |||
| 13 | MAX_KEYBOARD_SUBFOLDERS = 5 | 13 | MAX_KEYBOARD_SUBFOLDERS = 5 |
| 14 | 14 | ||
| 15 | # Supported processor types | 15 | # Supported processor types |
| 16 | CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK66FX1M0', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32L412', 'STM32L422', 'STM32L433', 'STM32L443' | 16 | CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK66FX1M0', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32L412', 'STM32L422', 'STM32L433', 'STM32L443', 'GD32VF103' |
| 17 | LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None | 17 | LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None |
| 18 | VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85' | 18 | VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85' |
| 19 | 19 | ||
diff --git a/platforms/chibios/boards/SIPEED_LONGAN_NANO/board/board.mk b/platforms/chibios/boards/SIPEED_LONGAN_NANO/board/board.mk new file mode 100644 index 000000000..960fc2678 --- /dev/null +++ b/platforms/chibios/boards/SIPEED_LONGAN_NANO/board/board.mk | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | # List of all the board related files. | ||
| 2 | BOARDSRC = ${CHIBIOS_CONTRIB}/os/hal/boards/SIPEED_LONGAN_NANO/board.c | ||
| 3 | |||
| 4 | # Required include directories | ||
| 5 | BOARDINC = ${CHIBIOS_CONTRIB}/os/hal/boards/SIPEED_LONGAN_NANO | ||
| 6 | |||
| 7 | # Shared variables | ||
| 8 | ALLCSRC += $(BOARDSRC) | ||
| 9 | ALLINC += $(BOARDINC) | ||
diff --git a/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/chconf.h b/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/chconf.h new file mode 100644 index 000000000..6e5adb0fe --- /dev/null +++ b/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/chconf.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | /* To compile the ChibiOS syscall stubs with picolibc | ||
| 18 | * the _reent struct has to be defined. */ | ||
| 19 | #if !defined(_FROM_ASM_) && defined(USE_PICOLIBC) | ||
| 20 | struct _reent; | ||
| 21 | #endif | ||
| 22 | |||
| 23 | #include_next <chconf.h> \ No newline at end of file | ||
diff --git a/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/mcuconf.h b/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/mcuconf.h new file mode 100644 index 000000000..ab086567e --- /dev/null +++ b/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/mcuconf.h | |||
| @@ -0,0 +1,302 @@ | |||
| 1 | /* | ||
| 2 | ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio | ||
| 3 | ChibiOS - Copyright (C) 2021 Stefan Kerkmann | ||
| 4 | |||
| 5 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 6 | you may not use this file except in compliance with the License. | ||
| 7 | You may obtain a copy of the License at | ||
| 8 | |||
| 9 | http://www.apache.org/licenses/LICENSE-2.0 | ||
| 10 | |||
| 11 | Unless required by applicable law or agreed to in writing, software | ||
| 12 | distributed under the License is distributed on an "AS IS" BASIS, | ||
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 14 | See the License for the specific language governing permissions and | ||
| 15 | limitations under the License. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #define GD32VF103_MCUCONF | ||
| 21 | #define GD32VF103CB | ||
| 22 | |||
| 23 | /* | ||
| 24 | * GD32VF103 drivers configuration. | ||
| 25 | * The following settings override the default settings present in | ||
| 26 | * the various device driver implementation headers. | ||
| 27 | * Note that the settings for each driver only have effect if the whole | ||
| 28 | * driver is enabled in halconf.h. | ||
| 29 | * | ||
| 30 | * IRQ priorities: | ||
| 31 | * 0...15 Lowest...Highest. | ||
| 32 | * | ||
| 33 | * DMA priorities: | ||
| 34 | * 0...3 Lowest...Highest. | ||
| 35 | */ | ||
| 36 | |||
| 37 | /* | ||
| 38 | * HAL driver system settings. | ||
| 39 | */ | ||
| 40 | |||
| 41 | #if defined(OVERCLOCK_120MHZ) | ||
| 42 | /* (8MHz / 2) * 30 = 120MHz Sysclock */ | ||
| 43 | #define GD32_ALLOW_120MHZ_SYSCLK | ||
| 44 | #define GD32_PLLMF_VALUE 30 | ||
| 45 | #define GD32_USBFSPSC GD32_USBFSPSC_DIV2P5 | ||
| 46 | #else | ||
| 47 | /* (8MHz / 2) * 24 = 96MHz Sysclock */ | ||
| 48 | #define GD32_PLLMF_VALUE 24 | ||
| 49 | #define GD32_USBFSPSC GD32_USBFSPSC_DIV2 | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #define GD32_NO_INIT FALSE | ||
| 53 | #define GD32_IRC8M_ENABLED TRUE | ||
| 54 | #define GD32_IRC40K_ENABLED FALSE | ||
| 55 | #define GD32_HXTAL_ENABLED TRUE | ||
| 56 | #define GD32_LXTAL_ENABLED FALSE | ||
| 57 | #define GD32_SCS GD32_SCS_PLL | ||
| 58 | #define GD32_PLLSEL GD32_PLLSEL_PREDV0 | ||
| 59 | #define GD32_PREDV0SEL GD32_PREDV0SEL_HXTAL | ||
| 60 | #define GD32_PREDV0_VALUE 2 | ||
| 61 | #define GD32_PREDV1_VALUE 2 | ||
| 62 | #define GD32_PLL1MF_VALUE 14 | ||
| 63 | #define GD32_PLL2MF_VALUE 13 | ||
| 64 | #define GD32_AHBPSC GD32_AHBPSC_DIV1 | ||
| 65 | #define GD32_APB1PSC GD32_APB1PSC_DIV2 | ||
| 66 | #define GD32_APB2PSC GD32_APB2PSC_DIV1 | ||
| 67 | #define GD32_ADCPSC GD32_ADCPSC_DIV16 | ||
| 68 | #define GD32_USB_CLOCK_REQUIRED TRUE | ||
| 69 | #define GD32_I2S_CLOCK_REQUIRED FALSE | ||
| 70 | #define GD32_CKOUT0SEL GD32_CKOUT0SEL_NOCLOCK | ||
| 71 | #define GD32_RTCSRC GD32_RTCSRC_NOCLOCK | ||
| 72 | #define GD32_PVD_ENABLE FALSE | ||
| 73 | #define GD32_LVDT GD32_LVDT_LEV0 | ||
| 74 | |||
| 75 | /* | ||
| 76 | * ECLIC system settings. | ||
| 77 | */ | ||
| 78 | #define ECLIC_TRIGGER_DEFAULT ECLIC_POSTIVE_EDGE_TRIGGER | ||
| 79 | #define ECLIC_DMA_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 80 | |||
| 81 | /* | ||
| 82 | * IRQ system settings. | ||
| 83 | */ | ||
| 84 | #define GD32_IRQ_EXTI0_PRIORITY 6 | ||
| 85 | #define GD32_IRQ_EXTI1_PRIORITY 6 | ||
| 86 | #define GD32_IRQ_EXTI2_PRIORITY 6 | ||
| 87 | #define GD32_IRQ_EXTI3_PRIORITY 6 | ||
| 88 | #define GD32_IRQ_EXTI4_PRIORITY 6 | ||
| 89 | #define GD32_IRQ_EXTI5_9_PRIORITY 6 | ||
| 90 | #define GD32_IRQ_EXTI10_15_PRIORITY 6 | ||
| 91 | #define GD32_IRQ_EXTI0_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 92 | #define GD32_IRQ_EXTI1_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 93 | #define GD32_IRQ_EXTI2_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 94 | #define GD32_IRQ_EXTI3_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 95 | #define GD32_IRQ_EXTI4_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 96 | #define GD32_IRQ_EXTI5_9_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 97 | #define GD32_IRQ_EXTI10_15_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 98 | |||
| 99 | /* | ||
| 100 | * ADC driver system settings. | ||
| 101 | */ | ||
| 102 | #define GD32_ADC_USE_ADC0 FALSE | ||
| 103 | #define GD32_ADC_ADC0_DMA_PRIORITY 2 | ||
| 104 | #define GD32_ADC_ADC0_IRQ_PRIORITY 6 | ||
| 105 | |||
| 106 | /* | ||
| 107 | * CAN driver system settings. | ||
| 108 | */ | ||
| 109 | #define GD32_CAN_USE_CAN0 FALSE | ||
| 110 | #define GD32_CAN_CAN0_IRQ_PRIORITY 11 | ||
| 111 | #define GD32_CAN_USE_CAN1 FALSE | ||
| 112 | #define GD32_CAN_CAN1_IRQ_PRIORITY 11 | ||
| 113 | #define GD32_CAN_CAN0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 114 | #define GD32_CAN_CAN1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 115 | |||
| 116 | /* | ||
| 117 | * CRC driver system settings. | ||
| 118 | */ | ||
| 119 | #define GD32_CRC_USE_CRC0 FALSE | ||
| 120 | #define GD32_CRC_CRC0_DMA_IRQ_PRIORITY 14 | ||
| 121 | #define GD32_CRC_CRC0_DMA_PRIORITY 2 | ||
| 122 | #define GD32_CRC_CRC0_DMA_STREAM GD32_DMA_STREAM_ID(0, 0) | ||
| 123 | #define CRC_USE_DMA FALSE | ||
| 124 | #define CRCSW_USE_CRC1 FALSE | ||
| 125 | #define CRCSW_CRC32_TABLE FALSE | ||
| 126 | #define CRCSW_CRC16_TABLE FALSE | ||
| 127 | #define CRCSW_PROGRAMMABLE FALSE | ||
| 128 | |||
| 129 | /* | ||
| 130 | * DAC driver system settings. | ||
| 131 | */ | ||
| 132 | #define GD32_DAC_USE_DAC_CH1 FALSE | ||
| 133 | #define GD32_DAC_USE_DAC_CH2 FALSE | ||
| 134 | |||
| 135 | /* | ||
| 136 | * GPT driver system settings. | ||
| 137 | */ | ||
| 138 | #define GD32_GPT_USE_TIM0 FALSE | ||
| 139 | #define GD32_GPT_USE_TIM1 FALSE | ||
| 140 | #define GD32_GPT_USE_TIM2 FALSE | ||
| 141 | #define GD32_GPT_USE_TIM3 FALSE | ||
| 142 | #define GD32_GPT_USE_TIM4 FALSE | ||
| 143 | #define GD32_GPT_TIM0_IRQ_PRIORITY 7 | ||
| 144 | #define GD32_GPT_TIM1_IRQ_PRIORITY 7 | ||
| 145 | #define GD32_GPT_TIM2_IRQ_PRIORITY 7 | ||
| 146 | #define GD32_GPT_TIM3_IRQ_PRIORITY 7 | ||
| 147 | #define GD32_GPT_TIM4_IRQ_PRIORITY 7 | ||
| 148 | #define GD32_GPT_TIM0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 149 | #define GD32_GPT_TIM1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 150 | #define GD32_GPT_TIM2_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 151 | #define GD32_GPT_TIM3_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 152 | #define GD32_GPT_TIM4_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 153 | #define GD32_GPT_TIM5_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 154 | #define GD32_GPT_TIM6_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 155 | |||
| 156 | /* | ||
| 157 | * I2S driver system settings. | ||
| 158 | */ | ||
| 159 | #define GD32_I2S_USE_SPI1 FALSE | ||
| 160 | #define GD32_I2S_USE_SPI2 FALSE | ||
| 161 | #define GD32_I2S_SPI1_IRQ_PRIORITY 10 | ||
| 162 | #define GD32_I2S_SPI2_IRQ_PRIORITY 10 | ||
| 163 | #define GD32_I2S_SPI1_DMA_PRIORITY 1 | ||
| 164 | #define GD32_I2S_SPI2_DMA_PRIORITY 1 | ||
| 165 | #define GD32_I2S_DMA_ERROR_HOOK(i2sp) osalSysHalt("DMA failure") | ||
| 166 | |||
| 167 | /* | ||
| 168 | * I2C driver system settings. | ||
| 169 | */ | ||
| 170 | #define GD32_I2C_USE_I2C0 FALSE | ||
| 171 | #define GD32_I2C_USE_I2C1 FALSE | ||
| 172 | #define GD32_I2C_BUSY_TIMEOUT 50 | ||
| 173 | #define GD32_I2C_I2C0_IRQ_PRIORITY 10 | ||
| 174 | #define GD32_I2C_I2C1_IRQ_PRIORITY 5 | ||
| 175 | #define GD32_I2C_I2C0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 176 | #define GD32_I2C_I2C1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 177 | #define GD32_I2C_I2C0_DMA_PRIORITY 2 | ||
| 178 | #define GD32_I2C_I2C1_DMA_PRIORITY 2 | ||
| 179 | #define GD32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") | ||
| 180 | |||
| 181 | /* | ||
| 182 | * ICU driver system settings. | ||
| 183 | */ | ||
| 184 | #define GD32_ICU_USE_TIM0 FALSE | ||
| 185 | #define GD32_ICU_USE_TIM1 FALSE | ||
| 186 | #define GD32_ICU_USE_TIM2 FALSE | ||
| 187 | #define GD32_ICU_USE_TIM3 FALSE | ||
| 188 | #define GD32_ICU_USE_TIM4 FALSE | ||
| 189 | #define GD32_ICU_TIM0_IRQ_PRIORITY 7 | ||
| 190 | #define GD32_ICU_TIM1_IRQ_PRIORITY 7 | ||
| 191 | #define GD32_ICU_TIM2_IRQ_PRIORITY 7 | ||
| 192 | #define GD32_ICU_TIM3_IRQ_PRIORITY 7 | ||
| 193 | #define GD32_ICU_TIM4_IRQ_PRIORITY 7 | ||
| 194 | #define GD32_ICU_TIM0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 195 | #define GD32_ICU_TIM1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 196 | #define GD32_ICU_TIM2_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 197 | #define GD32_ICU_TIM3_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 198 | #define GD32_ICU_TIM4_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 199 | |||
| 200 | /* | ||
| 201 | * PWM driver system settings. | ||
| 202 | */ | ||
| 203 | #define GD32_PWM_USE_ADVANCED FALSE | ||
| 204 | #define GD32_PWM_USE_TIM0 FALSE | ||
| 205 | #define GD32_PWM_USE_TIM1 FALSE | ||
| 206 | #define GD32_PWM_USE_TIM2 FALSE | ||
| 207 | #define GD32_PWM_USE_TIM3 FALSE | ||
| 208 | #define GD32_PWM_USE_TIM4 FALSE | ||
| 209 | #define GD32_PWM_TIM0_IRQ_PRIORITY 10 | ||
| 210 | #define GD32_PWM_TIM1_IRQ_PRIORITY 10 | ||
| 211 | #define GD32_PWM_TIM2_IRQ_PRIORITY 10 | ||
| 212 | #define GD32_PWM_TIM3_IRQ_PRIORITY 10 | ||
| 213 | #define GD32_PWM_TIM4_IRQ_PRIORITY 10 | ||
| 214 | #define GD32_PWM_TIM0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 215 | #define GD32_PWM_TIM1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 216 | #define GD32_PWM_TIM2_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 217 | #define GD32_PWM_TIM3_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 218 | #define GD32_PWM_TIM4_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 219 | |||
| 220 | /* | ||
| 221 | * RTC driver system settings. | ||
| 222 | */ | ||
| 223 | #define GD32_RTC_IRQ_PRIORITY 15 | ||
| 224 | #define GD32_RTC_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 225 | |||
| 226 | /* | ||
| 227 | * SERIAL driver system settings. | ||
| 228 | */ | ||
| 229 | #define GD32_SERIAL_USE_USART0 FALSE | ||
| 230 | #define GD32_SERIAL_USE_USART1 FALSE | ||
| 231 | #define GD32_SERIAL_USE_USART2 FALSE | ||
| 232 | #define GD32_SERIAL_USE_UART3 FALSE | ||
| 233 | #define GD32_SERIAL_USE_UART4 FALSE | ||
| 234 | #define GD32_SERIAL_USART0_PRIORITY 10 | ||
| 235 | #define GD32_SERIAL_USART1_PRIORITY 10 | ||
| 236 | #define GD32_SERIAL_USART2_PRIORITY 10 | ||
| 237 | #define GD32_SERIAL_UART3_PRIORITY 10 | ||
| 238 | #define GD32_SERIAL_UART4_PRIORITY 10 | ||
| 239 | #define GD32_SERIAL_USART0_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 240 | #define GD32_SERIAL_USART1_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 241 | #define GD32_SERIAL_USART2_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 242 | #define GD32_SERIAL_UART3_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 243 | #define GD32_SERIAL_UART4_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 244 | |||
| 245 | /* | ||
| 246 | * SPI driver system settings. | ||
| 247 | */ | ||
| 248 | #define GD32_SPI_USE_SPI0 FALSE | ||
| 249 | #define GD32_SPI_USE_SPI1 FALSE | ||
| 250 | #define GD32_SPI_USE_SPI2 FALSE | ||
| 251 | #define GD32_SPI_SPI0_DMA_PRIORITY 1 | ||
| 252 | #define GD32_SPI_SPI1_DMA_PRIORITY 1 | ||
| 253 | #define GD32_SPI_SPI2_DMA_PRIORITY 1 | ||
| 254 | #define GD32_SPI_SPI0_IRQ_PRIORITY 10 | ||
| 255 | #define GD32_SPI_SPI1_IRQ_PRIORITY 10 | ||
| 256 | #define GD32_SPI_SPI2_IRQ_PRIORITY 10 | ||
| 257 | #define GD32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") | ||
| 258 | |||
| 259 | /* | ||
| 260 | * ST driver system settings. | ||
| 261 | */ | ||
| 262 | #define GD32_ST_IRQ_PRIORITY 10 | ||
| 263 | #define GD32_ST_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 264 | #define GD32_ST_USE_TIMER 1 | ||
| 265 | |||
| 266 | /* | ||
| 267 | * UART driver system settings. | ||
| 268 | */ | ||
| 269 | #define GD32_UART_USE_USART0 FALSE | ||
| 270 | #define GD32_UART_USE_USART1 FALSE | ||
| 271 | #define GD32_UART_USE_USART2 FALSE | ||
| 272 | #define GD32_UART_USE_UART3 FALSE | ||
| 273 | #define GD32_UART_USE_UART4 FALSE | ||
| 274 | #define GD32_UART_USART0_IRQ_PRIORITY 10 | ||
| 275 | #define GD32_UART_USART1_IRQ_PRIORITY 10 | ||
| 276 | #define GD32_UART_USART2_IRQ_PRIORITY 10 | ||
| 277 | #define GD32_UART_UART3_IRQ_PRIORITY 10 | ||
| 278 | #define GD32_UART_UART4_IRQ_PRIORITY 10 | ||
| 279 | #define GD32_UART_USART0_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 280 | #define GD32_UART_USART1_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 281 | #define GD32_UART_USART2_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 282 | #define GD32_UART_UART3_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 283 | #define GD32_UART_UART4_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 284 | #define GD32_UART_USART0_DMA_PRIORITY 3 | ||
| 285 | #define GD32_UART_USART1_DMA_PRIORITY 3 | ||
| 286 | #define GD32_UART_USART2_DMA_PRIORITY 3 | ||
| 287 | #define GD32_UART_UART3_DMA_PRIORITY 3 | ||
| 288 | #define GD32_UART_UART4_DMA_PRIORITY 3 | ||
| 289 | #define GD32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") | ||
| 290 | |||
| 291 | /* | ||
| 292 | * USB driver system settings. | ||
| 293 | */ | ||
| 294 | #define GD32_USB_USE_USBFS TRUE | ||
| 295 | #define GD32_USB_USBFS_IRQ_PRIORITY 10 | ||
| 296 | #define GD32_USB_USBFS_IRQ_TRIGGER ECLIC_TRIGGER_DEFAULT | ||
| 297 | #define GD32_USB_USBFS_RX_FIFO_SIZE 256 | ||
| 298 | |||
| 299 | /* | ||
| 300 | * WDG driver system settings. | ||
| 301 | */ | ||
| 302 | #define GD32_WDG_USE_FWDGT FALSE | ||
diff --git a/platforms/chibios/drivers/analog.c b/platforms/chibios/drivers/analog.c index 8c476fcac..eb437665f 100644 --- a/platforms/chibios/drivers/analog.c +++ b/platforms/chibios/drivers/analog.c | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | // Otherwise assume V3 | 38 | // Otherwise assume V3 |
| 39 | #if defined(STM32F0XX) || defined(STM32L0XX) | 39 | #if defined(STM32F0XX) || defined(STM32L0XX) |
| 40 | # define USE_ADCV1 | 40 | # define USE_ADCV1 |
| 41 | #elif defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) | 41 | #elif defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(GD32VF103) |
| 42 | # define USE_ADCV2 | 42 | # define USE_ADCV2 |
| 43 | #endif | 43 | #endif |
| 44 | 44 | ||
| @@ -75,7 +75,7 @@ | |||
| 75 | 75 | ||
| 76 | /* User configurable ADC options */ | 76 | /* User configurable ADC options */ |
| 77 | #ifndef ADC_COUNT | 77 | #ifndef ADC_COUNT |
| 78 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F4XX) | 78 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F4XX) || defined(GD32VF103) |
| 79 | # define ADC_COUNT 1 | 79 | # define ADC_COUNT 1 |
| 80 | # elif defined(STM32F3XX) | 80 | # elif defined(STM32F3XX) |
| 81 | # define ADC_COUNT 4 | 81 | # define ADC_COUNT 4 |
| @@ -122,8 +122,8 @@ static ADCConversionGroup adcConversionGroup = { | |||
| 122 | .cfgr1 = ADC_CFGR1_CONT | ADC_RESOLUTION, | 122 | .cfgr1 = ADC_CFGR1_CONT | ADC_RESOLUTION, |
| 123 | .smpr = ADC_SAMPLING_RATE, | 123 | .smpr = ADC_SAMPLING_RATE, |
| 124 | #elif defined(USE_ADCV2) | 124 | #elif defined(USE_ADCV2) |
| 125 | # if !defined(STM32F1XX) | 125 | # if !defined(STM32F1XX) && !defined(GD32VF103) |
| 126 | .cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without... | 126 | .cr2 = ADC_CR2_SWSTART, // F103 seem very unhappy with, F401 seems very unhappy without... |
| 127 | # endif | 127 | # endif |
| 128 | .smpr2 = ADC_SMPR2_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN9(ADC_SAMPLING_RATE), | 128 | .smpr2 = ADC_SMPR2_SMP_AN0(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN1(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN2(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN3(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN4(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN5(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN6(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN7(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN8(ADC_SAMPLING_RATE) | ADC_SMPR2_SMP_AN9(ADC_SAMPLING_RATE), |
| 129 | .smpr1 = ADC_SMPR1_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN15(ADC_SAMPLING_RATE), | 129 | .smpr1 = ADC_SMPR1_SMP_AN10(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN11(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN12(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN13(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN14(ADC_SAMPLING_RATE) | ADC_SMPR1_SMP_AN15(ADC_SAMPLING_RATE), |
| @@ -220,7 +220,7 @@ __attribute__((weak)) adc_mux pinToMux(pin_t pin) { | |||
| 220 | case F9: return TO_MUX( ADC_CHANNEL_IN7, 2 ); | 220 | case F9: return TO_MUX( ADC_CHANNEL_IN7, 2 ); |
| 221 | case F10: return TO_MUX( ADC_CHANNEL_IN8, 2 ); | 221 | case F10: return TO_MUX( ADC_CHANNEL_IN8, 2 ); |
| 222 | # endif | 222 | # endif |
| 223 | #elif defined(STM32F1XX) | 223 | #elif defined(STM32F1XX) || defined(GD32VF103) |
| 224 | case A0: return TO_MUX( ADC_CHANNEL_IN0, 0 ); | 224 | case A0: return TO_MUX( ADC_CHANNEL_IN0, 0 ); |
| 225 | case A1: return TO_MUX( ADC_CHANNEL_IN1, 0 ); | 225 | case A1: return TO_MUX( ADC_CHANNEL_IN1, 0 ); |
| 226 | case A2: return TO_MUX( ADC_CHANNEL_IN2, 0 ); | 226 | case A2: return TO_MUX( ADC_CHANNEL_IN2, 0 ); |
diff --git a/platforms/chibios/drivers/ws2812.c b/platforms/chibios/drivers/ws2812.c index ffcdcff24..b46c46ae5 100644 --- a/platforms/chibios/drivers/ws2812.c +++ b/platforms/chibios/drivers/ws2812.c | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | /* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */ | 6 | /* Adapted from https://github.com/bigjosh/SimpleNeoPixelDemo/ */ |
| 7 | 7 | ||
| 8 | #ifndef NOP_FUDGE | 8 | #ifndef NOP_FUDGE |
| 9 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) | 9 | # if defined(STM32F0XX) || defined(STM32F1XX) || defined(GD32VF103) || defined(STM32F3XX) || defined(STM32F4XX) || defined(STM32L0XX) |
| 10 | # define NOP_FUDGE 0.4 | 10 | # define NOP_FUDGE 0.4 |
| 11 | # else | 11 | # else |
| 12 | # error("NOP_FUDGE configuration required") | 12 | # error("NOP_FUDGE configuration required") |
diff --git a/platforms/chibios/flash.mk b/platforms/chibios/flash.mk index c0b32c2f2..31f69595d 100644 --- a/platforms/chibios/flash.mk +++ b/platforms/chibios/flash.mk | |||
| @@ -82,6 +82,8 @@ else ifeq ($(strip $(MCU_FAMILY)),MIMXRT1062) | |||
| 82 | $(UNSYNC_OUTPUT_CMD) && $(call EXEC_TEENSY) | 82 | $(UNSYNC_OUTPUT_CMD) && $(call EXEC_TEENSY) |
| 83 | else ifeq ($(strip $(MCU_FAMILY)),STM32) | 83 | else ifeq ($(strip $(MCU_FAMILY)),STM32) |
| 84 | $(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL) | 84 | $(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL) |
| 85 | else ifeq ($(strip $(MCU_FAMILY)),GD32V) | ||
| 86 | $(UNSYNC_OUTPUT_CMD) && $(call EXEC_DFU_UTIL) | ||
| 85 | else | 87 | else |
| 86 | $(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)" | 88 | $(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)" |
| 87 | endif | 89 | endif |
diff --git a/quantum/mcu_selection.mk b/quantum/mcu_selection.mk index 622b4a82f..7c4a617af 100644 --- a/quantum/mcu_selection.mk +++ b/quantum/mcu_selection.mk | |||
| @@ -541,6 +541,37 @@ ifneq (,$(filter $(MCU),STM32L412 STM32L422)) | |||
| 541 | UF2_FAMILY ?= STM32L4 | 541 | UF2_FAMILY ?= STM32L4 |
| 542 | endif | 542 | endif |
| 543 | 543 | ||
| 544 | ifneq ($(findstring GD32VF103, $(MCU)),) | ||
| 545 | # RISC-V | ||
| 546 | MCU = risc-v | ||
| 547 | |||
| 548 | # RISC-V extensions and abi configuration | ||
| 549 | MCU_ARCH = rv32imac | ||
| 550 | MCU_ABI = ilp32 | ||
| 551 | MCU_CMODEL = medlow | ||
| 552 | |||
| 553 | ## chip/board settings | ||
| 554 | # - the next two should match the directories in | ||
| 555 | # <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) | ||
| 556 | MCU_FAMILY = GD32V | ||
| 557 | MCU_SERIES = GD32VF103 | ||
| 558 | |||
| 559 | # Linker script to use | ||
| 560 | # - it should exist either in <chibios>/os/common/startup/RISCV-ECLIC/compilers/GCC/ld/ | ||
| 561 | # or <keyboard_dir>/ld/ | ||
| 562 | MCU_LDSCRIPT ?= GD32VF103xB | ||
| 563 | |||
| 564 | # Startup code to use | ||
| 565 | # - it should exist in <chibios>/os/common/startup/RISCV-ECLIC/compilers/GCC/mk/ | ||
| 566 | MCU_STARTUP ?= gd32vf103 | ||
| 567 | |||
| 568 | # Board: it should exist either in <chibios>/os/hal/boards/, | ||
| 569 | # <keyboard_dir>/boards/, or drivers/boards/ | ||
| 570 | BOARD ?= SIPEED_LONGAN_NANO | ||
| 571 | |||
| 572 | USE_FPU ?= no | ||
| 573 | endif | ||
| 574 | |||
| 544 | ifneq (,$(filter $(MCU),at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647 at90usb1286 at90usb1287)) | 575 | ifneq (,$(filter $(MCU),at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647 at90usb1286 at90usb1287)) |
| 545 | PROTOCOL = LUFA | 576 | PROTOCOL = LUFA |
| 546 | 577 | ||
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk index 18839710b..cae840fa4 100644 --- a/tmk_core/chibios.mk +++ b/tmk_core/chibios.mk | |||
| @@ -27,29 +27,62 @@ endif | |||
| 27 | OPT_OS = chibios | 27 | OPT_OS = chibios |
| 28 | CHIBIOS = $(TOP_DIR)/lib/chibios | 28 | CHIBIOS = $(TOP_DIR)/lib/chibios |
| 29 | CHIBIOS_CONTRIB = $(TOP_DIR)/lib/chibios-contrib | 29 | CHIBIOS_CONTRIB = $(TOP_DIR)/lib/chibios-contrib |
| 30 | # Startup files. Try a few different locations, for compability with old versions and | 30 | |
| 31 | # for things hardware in the contrib repository | 31 | # |
| 32 | STARTUP_MK = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk | 32 | # Startup, Port and Platform support selection |
| 33 | ifeq ("$(wildcard $(STARTUP_MK))","") | 33 | ############################################################################## |
| 34 | STARTUP_MK = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk | 34 | |
| 35 | ifeq ("$(wildcard $(STARTUP_MK))","") | 35 | ifeq ($(strip $(MCU)), risc-v) |
| 36 | STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk | 36 | # RISC-V Support |
| 37 | endif | 37 | # As of 7.4.2021 there is only one supported RISC-V platform in Chibios-Contrib, |
| 38 | # therefore all required settings are hard-coded | ||
| 39 | STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/RISCV-ECLIC/compilers/GCC/mk/startup_$(MCU_STARTUP).mk | ||
| 40 | PORT_V = $(CHIBIOS_CONTRIB)/os/common/ports/RISCV-ECLIC/compilers/GCC/mk/port.mk | ||
| 41 | RULESPATH = $(CHIBIOS_CONTRIB)/os/common/startup/RISCV-ECLIC/compilers/GCC | ||
| 42 | PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/GD/GD32VF103/platform.mk | ||
| 43 | else | ||
| 44 | # ARM Support | ||
| 45 | # Startup files. Try a few different locations, for compability with old versions and | ||
| 46 | # for things hardware in the contrib repository | ||
| 47 | STARTUP_MK = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk | ||
| 48 | ifeq ("$(wildcard $(STARTUP_MK))","") | ||
| 49 | STARTUP_MK = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk | ||
| 50 | ifeq ("$(wildcard $(STARTUP_MK))","") | ||
| 51 | STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk | ||
| 52 | endif | ||
| 53 | endif | ||
| 54 | |||
| 55 | # Compability with old version | ||
| 56 | PORT_V = $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk | ||
| 57 | ifeq ("$(wildcard $(PORT_V))","") | ||
| 58 | PORT_V = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk | ||
| 59 | endif | ||
| 60 | |||
| 61 | RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC | ||
| 62 | ifeq ("$(wildcard $(RULESPATH)/rules.mk)","") | ||
| 63 | RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC | ||
| 64 | endif | ||
| 38 | endif | 65 | endif |
| 39 | include $(STARTUP_MK) | ||
| 40 | # HAL-OSAL files (optional). | ||
| 41 | include $(CHIBIOS)/os/hal/hal.mk | ||
| 42 | 66 | ||
| 43 | ifeq ("$(PLATFORM_NAME)","") | 67 | ifeq ("$(PLATFORM_NAME)","") |
| 44 | PLATFORM_NAME = platform | 68 | PLATFORM_NAME = platform |
| 45 | endif | 69 | endif |
| 46 | 70 | ||
| 47 | PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk | ||
| 48 | ifeq ("$(wildcard $(PLATFORM_MK))","") | 71 | ifeq ("$(wildcard $(PLATFORM_MK))","") |
| 49 | PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk | 72 | PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk |
| 73 | ifeq ("$(wildcard $(PLATFORM_MK))","") | ||
| 74 | PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk | ||
| 75 | endif | ||
| 50 | endif | 76 | endif |
| 77 | |||
| 78 | include $(STARTUP_MK) | ||
| 79 | include $(PORT_V) | ||
| 51 | include $(PLATFORM_MK) | 80 | include $(PLATFORM_MK) |
| 52 | 81 | ||
| 82 | # | ||
| 83 | # Board support selection. | ||
| 84 | ############################################################################## | ||
| 85 | |||
| 53 | BOARD_MK := | 86 | BOARD_MK := |
| 54 | 87 | ||
| 55 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/board.mk)","") | 88 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/board.mk)","") |
| @@ -77,13 +110,19 @@ else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/board/board | |||
| 77 | endif | 110 | endif |
| 78 | 111 | ||
| 79 | ifeq ("$(wildcard $(BOARD_MK))","") | 112 | ifeq ("$(wildcard $(BOARD_MK))","") |
| 80 | BOARD_MK = $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk | 113 | BOARD_MK = $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk |
| 81 | ifeq ("$(wildcard $(BOARD_MK))","") | 114 | ifeq ("$(wildcard $(BOARD_MK))","") |
| 82 | BOARD_MK = $(CHIBIOS_CONTRIB)/os/hal/boards/$(BOARD)/board.mk | 115 | BOARD_MK = $(CHIBIOS_CONTRIB)/os/hal/boards/$(BOARD)/board.mk |
| 83 | endif | 116 | endif |
| 84 | endif | 117 | endif |
| 85 | 118 | ||
| 86 | # Bootloader address | 119 | include $(BOARD_MK) |
| 120 | |||
| 121 | # | ||
| 122 | # Bootloader selection. | ||
| 123 | ############################################################################## | ||
| 124 | |||
| 125 | # Set bootloader address if supplied. | ||
| 87 | ifdef STM32_BOOTLOADER_ADDRESS | 126 | ifdef STM32_BOOTLOADER_ADDRESS |
| 88 | OPT_DEFS += -DSTM32_BOOTLOADER_ADDRESS=$(STM32_BOOTLOADER_ADDRESS) | 127 | OPT_DEFS += -DSTM32_BOOTLOADER_ADDRESS=$(STM32_BOOTLOADER_ADDRESS) |
| 89 | endif | 128 | endif |
| @@ -113,6 +152,10 @@ else ifneq ("$(wildcard $(BOARD_PATH)/configs/bootloader_defs.h)","") | |||
| 113 | OPT_DEFS += -include $(BOARD_PATH)/configs/bootloader_defs.h | 152 | OPT_DEFS += -include $(BOARD_PATH)/configs/bootloader_defs.h |
| 114 | endif | 153 | endif |
| 115 | 154 | ||
| 155 | # | ||
| 156 | # ChibiOS config selection. | ||
| 157 | ############################################################################## | ||
| 158 | |||
| 116 | # Work out the config file directories | 159 | # Work out the config file directories |
| 117 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/chconf.h)","") | 160 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/chconf.h)","") |
| 118 | CHCONFDIR = $(KEYBOARD_PATH_5) | 161 | CHCONFDIR = $(KEYBOARD_PATH_5) |
| @@ -130,6 +173,10 @@ else ifneq ("$(wildcard $(TOP_DIR)/platforms/boards/chibios/common/configs/chcon | |||
| 130 | CHCONFDIR = $(TOP_DIR)/platforms/chibios/boards/common/configs | 173 | CHCONFDIR = $(TOP_DIR)/platforms/chibios/boards/common/configs |
| 131 | endif | 174 | endif |
| 132 | 175 | ||
| 176 | # | ||
| 177 | # HAL config selection. | ||
| 178 | ############################################################################## | ||
| 179 | |||
| 133 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/halconf.h)","") | 180 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/halconf.h)","") |
| 134 | HALCONFDIR = $(KEYBOARD_PATH_5) | 181 | HALCONFDIR = $(KEYBOARD_PATH_5) |
| 135 | else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/halconf.h)","") | 182 | else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/halconf.h)","") |
| @@ -146,40 +193,10 @@ else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/common/configs/halco | |||
| 146 | HALCONFDIR = $(TOP_DIR)/platforms/chibios/boards/common/configs | 193 | HALCONFDIR = $(TOP_DIR)/platforms/chibios/boards/common/configs |
| 147 | endif | 194 | endif |
| 148 | 195 | ||
| 149 | # HAL-OSAL files (optional). | 196 | # |
| 150 | include $(CHIBIOS)/os/hal/hal.mk | 197 | # Linker script selection. |
| 151 | 198 | ############################################################################## | |
| 152 | ifeq ("$(PLATFORM_NAME)","") | ||
| 153 | PLATFORM_NAME = platform | ||
| 154 | endif | ||
| 155 | |||
| 156 | PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk | ||
| 157 | ifeq ("$(wildcard $(PLATFORM_MK))","") | ||
| 158 | PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk | ||
| 159 | endif | ||
| 160 | include $(PLATFORM_MK) | ||
| 161 | |||
| 162 | |||
| 163 | include $(BOARD_MK) | ||
| 164 | -include $(CHIBIOS)/os/hal/osal/rt/osal.mk # ChibiOS <= 19.x | ||
| 165 | -include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk # ChibiOS >= 20.x | ||
| 166 | # RTOS files (optional). | ||
| 167 | include $(CHIBIOS)/os/rt/rt.mk | ||
| 168 | # Compability with old version | ||
| 169 | PORT_V = $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk | ||
| 170 | ifeq ("$(wildcard $(PORT_V))","") | ||
| 171 | PORT_V = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk | ||
| 172 | endif | ||
| 173 | include $(PORT_V) | ||
| 174 | # Other files (optional). | ||
| 175 | include $(CHIBIOS)/os/hal/lib/streams/streams.mk | ||
| 176 | |||
| 177 | RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC | ||
| 178 | ifeq ("$(wildcard $(RULESPATH)/rules.mk)","") | ||
| 179 | RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC | ||
| 180 | endif | ||
| 181 | 199 | ||
| 182 | # Define linker script file here | ||
| 183 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/ld/$(MCU_LDSCRIPT).ld)","") | 200 | ifneq ("$(wildcard $(KEYBOARD_PATH_5)/ld/$(MCU_LDSCRIPT).ld)","") |
| 184 | LDSCRIPT = $(KEYBOARD_PATH_5)/ld/$(MCU_LDSCRIPT).ld | 201 | LDSCRIPT = $(KEYBOARD_PATH_5)/ld/$(MCU_LDSCRIPT).ld |
| 185 | else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/ld/$(MCU_LDSCRIPT).ld)","") | 202 | else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/ld/$(MCU_LDSCRIPT).ld)","") |
| @@ -202,17 +219,30 @@ else | |||
| 202 | LDSCRIPT = $(STARTUPLD)/$(MCU_LDSCRIPT).ld | 219 | LDSCRIPT = $(STARTUPLD)/$(MCU_LDSCRIPT).ld |
| 203 | endif | 220 | endif |
| 204 | 221 | ||
| 222 | # | ||
| 223 | # Include ChibiOS makefiles. | ||
| 224 | ############################################################################## | ||
| 225 | |||
| 226 | # HAL-OSAL files (optional). | ||
| 227 | include $(CHIBIOS)/os/hal/hal.mk | ||
| 228 | -include $(CHIBIOS)/os/hal/osal/rt/osal.mk # ChibiOS <= 19.x | ||
| 229 | -include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk # ChibiOS >= 20.x | ||
| 230 | # RTOS files (optional). | ||
| 231 | include $(CHIBIOS)/os/rt/rt.mk | ||
| 232 | # Other files (optional). | ||
| 233 | include $(CHIBIOS)/os/hal/lib/streams/streams.mk | ||
| 234 | |||
| 205 | CHIBISRC = $(STARTUPSRC) \ | 235 | CHIBISRC = $(STARTUPSRC) \ |
| 206 | $(KERNSRC) \ | 236 | $(KERNSRC) \ |
| 207 | $(PORTSRC) \ | 237 | $(PORTSRC) \ |
| 208 | $(OSALSRC) \ | 238 | $(OSALSRC) \ |
| 209 | $(HALSRC) \ | 239 | $(HALSRC) \ |
| 210 | $(PLATFORMSRC) \ | 240 | $(PLATFORMSRC) \ |
| 211 | $(BOARDSRC) \ | 241 | $(BOARDSRC) \ |
| 212 | $(STREAMSSRC) \ | 242 | $(STREAMSSRC) \ |
| 213 | $(CHIBIOS)/os/various/syscalls.c \ | 243 | $(CHIBIOS)/os/various/syscalls.c \ |
| 214 | $(PLATFORM_COMMON_DIR)/syscall-fallbacks.c \ | 244 | $(PLATFORM_COMMON_DIR)/syscall-fallbacks.c \ |
| 215 | $(PLATFORM_COMMON_DIR)/wait.c | 245 | $(PLATFORM_COMMON_DIR)/wait.c |
| 216 | 246 | ||
| 217 | # Ensure the ASM files are not subjected to LTO -- it'll strip out interrupt handlers otherwise. | 247 | # Ensure the ASM files are not subjected to LTO -- it'll strip out interrupt handlers otherwise. |
| 218 | QUANTUM_LIB_SRC += $(STARTUPASM) $(PORTASM) $(OSALASM) $(PLATFORMASM) | 248 | QUANTUM_LIB_SRC += $(STARTUPASM) $(PORTASM) $(OSALASM) $(PLATFORMASM) |
| @@ -247,9 +277,9 @@ else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs/hal | |||
| 247 | endif | 277 | endif |
| 248 | 278 | ||
| 249 | ifeq ($(strip $(USE_CHIBIOS_CONTRIB)),yes) | 279 | ifeq ($(strip $(USE_CHIBIOS_CONTRIB)),yes) |
| 250 | include $(CHIBIOS_CONTRIB)/os/hal/hal.mk | 280 | include $(CHIBIOS_CONTRIB)/os/hal/hal.mk |
| 251 | CHIBISRC += $(PLATFORMSRC_CONTRIB) $(HALSRC_CONTRIB) | 281 | CHIBISRC += $(PLATFORMSRC_CONTRIB) $(HALSRC_CONTRIB) |
| 252 | EXTRAINCDIRS += $(PLATFORMINC_CONTRIB) $(HALINC_CONTRIB) $(CHIBIOS_CONTRIB)/os/various | 282 | EXTRAINCDIRS += $(PLATFORMINC_CONTRIB) $(HALINC_CONTRIB) $(CHIBIOS_CONTRIB)/os/various |
| 253 | endif | 283 | endif |
| 254 | 284 | ||
| 255 | # | 285 | # |
| @@ -267,61 +297,123 @@ ifneq ("$(wildcard $(BOARD_PATH)/configs/post_config.h)","") | |||
| 267 | endif | 297 | endif |
| 268 | 298 | ||
| 269 | ############################################################################## | 299 | ############################################################################## |
| 270 | # Compiler settings | 300 | # Compiler and Linker configuration |
| 271 | # | 301 | # |
| 272 | CC = arm-none-eabi-gcc | 302 | |
| 273 | OBJCOPY = arm-none-eabi-objcopy | 303 | # Use defined stack sizes of the main thread in linker scripts |
| 274 | OBJDUMP = arm-none-eabi-objdump | 304 | LDSYMBOLS =--defsym=__process_stack_size__=$(USE_PROCESS_STACKSIZE),--defsym=__main_stack_size__=$(USE_EXCEPTIONS_STACKSIZE) |
| 275 | SIZE = arm-none-eabi-size | 305 | |
| 276 | AR = arm-none-eabi-ar | 306 | # Shared Compiler flags for all toolchains |
| 277 | NM = arm-none-eabi-nm | 307 | SHARED_CFLAGS = -fomit-frame-pointer \ |
| 278 | HEX = $(OBJCOPY) -O $(FORMAT) | 308 | -ffunction-sections \ |
| 279 | EEP = | 309 | -fdata-sections \ |
| 280 | BIN = $(OBJCOPY) -O binary | 310 | -fno-common \ |
| 281 | 311 | -fshort-wchar | |
| 282 | THUMBFLAGS = -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -mthumb -DTHUMB | 312 | |
| 283 | 313 | # Shared Linker flags for all toolchains | |
| 284 | COMPILEFLAGS += -fomit-frame-pointer | 314 | SHARED_LDFLAGS = -T $(LDSCRIPT) \ |
| 285 | COMPILEFLAGS += -falign-functions=16 | 315 | -Wl,$(LDSYMBOLS) \ |
| 286 | COMPILEFLAGS += -ffunction-sections | 316 | -Wl,--gc-sections \ |
| 287 | COMPILEFLAGS += -fdata-sections | 317 | -nostartfiles |
| 288 | COMPILEFLAGS += -fno-common | 318 | |
| 289 | COMPILEFLAGS += -fshort-wchar | 319 | ifeq ($(strip $(MCU)), risc-v) |
| 290 | COMPILEFLAGS += $(THUMBFLAGS) | 320 | # RISC-V toolchain specific configuration |
| 291 | 321 | # Find suitable GCC compiler | |
| 292 | # FPU options default (Cortex-M4 and Cortex-M7 single precision). | 322 | ifeq ($(strip $(TOOLCHAIN)),) |
| 293 | USE_FPU_OPT ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant | 323 | ifneq ($(shell which riscv32-unknown-elf-gcc 2>/dev/null),) |
| 294 | 324 | TOOLCHAIN = riscv32-unknown-elf- | |
| 295 | # FPU-related options | 325 | else |
| 296 | USE_FPU ?= no | 326 | ifneq ($(shell which riscv64-unknown-elf-gcc 2>/dev/null),) |
| 297 | ifneq ($(USE_FPU),no) | 327 | TOOLCHAIN = riscv64-unknown-elf- |
| 298 | COMPILEFLAGS += $(USE_FPU_OPT) | 328 | else |
| 299 | OPT_DEFS += -DCORTEX_USE_FPU=TRUE | 329 | $(error "No RISC-V toolchain found. Can't find riscv32-unknown-elf-gcc or riscv64-unknown-elf-gcc found in your systems PATH variable. Please install a valid toolchain and make it accessible!") |
| 330 | endif | ||
| 331 | endif | ||
| 332 | endif | ||
| 333 | |||
| 334 | # Default to compiling with picolibc for RISC-V targets if available, | ||
| 335 | # which is available by default on current (bullseye) debian based systems. | ||
| 336 | ifeq ($(shell $(TOOLCHAIN)gcc --specs=picolibc.specs -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) | ||
| 337 | # Toolchain specific Compiler flags | ||
| 338 | # Note that we still link with our own linker script | ||
| 339 | # by providing it via the -T flag above. | ||
| 340 | TOOLCHAIN_CFLAGS = --specs=picolibc.specs | ||
| 341 | |||
| 342 | # Tell QMK that we are compiling with picolibc. | ||
| 343 | OPT_DEFS += -DUSE_PICOLIBC | ||
| 344 | endif | ||
| 345 | |||
| 346 | # MCU architecture flags | ||
| 347 | MCUFLAGS = -march=$(MCU_ARCH) \ | ||
| 348 | -mabi=$(MCU_ABI) \ | ||
| 349 | -mcmodel=$(MCU_CMODEL) \ | ||
| 350 | -mstrict-align | ||
| 300 | else | 351 | else |
| 301 | OPT_DEFS += -DCORTEX_USE_FPU=FALSE | 352 | # ARM toolchain specific configuration |
| 353 | TOOLCHAIN ?= arm-none-eabi- | ||
| 354 | |||
| 355 | # Toolchain specific Linker flags | ||
| 356 | TOOLCHAIN_LDFLAGS = -Wl,--no-wchar-size-warning \ | ||
| 357 | --specs=nano.specs | ||
| 358 | |||
| 359 | # MCU architecture flags | ||
| 360 | MCUFLAGS = -mcpu=$(MCU) \ | ||
| 361 | -mthumb -DTHUMB_PRESENT \ | ||
| 362 | -mno-thumb-interwork -DTHUMB_NO_INTERWORKING \ | ||
| 363 | -mno-unaligned-access | ||
| 364 | |||
| 365 | # Some ARM cores like the M4 and M7 have floating point units which can be enabled | ||
| 366 | USE_FPU ?= no | ||
| 367 | |||
| 368 | ifneq ($(USE_FPU),no) | ||
| 369 | OPT_DEFS += -DCORTEX_USE_FPU=TRUE | ||
| 370 | |||
| 371 | # Default is single precision floats | ||
| 372 | USE_FPU_OPT ?= -mfloat-abi=hard \ | ||
| 373 | -mfpu=fpv4-sp-d16 \ | ||
| 374 | -fsingle-precision-constant | ||
| 375 | |||
| 376 | MCUFLAGS += $(USE_FPU_OPT) | ||
| 377 | else | ||
| 378 | OPT_DEFS += -DCORTEX_USE_FPU=FALSE | ||
| 379 | endif | ||
| 302 | endif | 380 | endif |
| 303 | 381 | ||
| 304 | CFLAGS += $(COMPILEFLAGS) | 382 | # Assembler flags |
| 383 | ASFLAGS += $(SHARED_ASFLAGS) $(TOOLCHAIN_ASFLAGS) | ||
| 305 | 384 | ||
| 306 | ASFLAGS += $(THUMBFLAGS) | 385 | # C Compiler flags |
| 386 | CFLAGS += $(SHARED_CFLAGS) $(TOOLCHAIN_CFLAGS) | ||
| 307 | 387 | ||
| 308 | CXXFLAGS += $(COMPILEFLAGS) | 388 | # C++ Compiler flags |
| 309 | CXXFLAGS += -fno-rtti | 389 | CXXFLAGS += $(CFLAGS) $(SHARED_CXXFLAGS) $(TOOLCHAIN_CXXFLAGS) -fno-rtti |
| 310 | 390 | ||
| 311 | LDFLAGS +=-Wl,--gc-sections | 391 | # Linker flags |
| 312 | LDFLAGS +=-Wl,--no-wchar-size-warning | 392 | LDFLAGS += $(SHARED_LDFLAGS) $(TOOLCHAIN_LDFLAGS) $(MCUFLAGS) |
| 313 | LDFLAGS += -mno-thumb-interwork -mthumb | ||
| 314 | LDSYMBOLS =,--defsym=__process_stack_size__=$(USE_PROCESS_STACKSIZE) | ||
| 315 | LDSYMBOLS :=$(LDSYMBOLS),--defsym=__main_stack_size__=$(USE_EXCEPTIONS_STACKSIZE) | ||
| 316 | LDFLAGS += -Wl,--script=$(LDSCRIPT)$(LDSYMBOLS) | ||
| 317 | LDFLAGS += --specs=nano.specs | ||
| 318 | 393 | ||
| 394 | # Tell QMK that we are hosting it on ChibiOS. | ||
| 319 | OPT_DEFS += -DPROTOCOL_CHIBIOS | 395 | OPT_DEFS += -DPROTOCOL_CHIBIOS |
| 320 | 396 | ||
| 321 | # Workaround to stop ChibiOS from complaining about new GCC -- it's been fixed for 7/8/9 already | 397 | # Speed up recompilations by opt-in usage of ccache |
| 322 | OPT_DEFS += -DPORT_IGNORE_GCC_VERSION_CHECK=1 | 398 | USE_CCACHE ?= no |
| 399 | ifneq ($(USE_CCACHE),no) | ||
| 400 | CC_PREFIX ?= ccache | ||
| 401 | endif | ||
| 402 | |||
| 403 | # Construct GCC toolchain | ||
| 404 | CC = $(CC_PREFIX) $(TOOLCHAIN)gcc | ||
| 405 | OBJCOPY = $(TOOLCHAIN)objcopy | ||
| 406 | OBJDUMP = $(TOOLCHAIN)objdump | ||
| 407 | SIZE = $(TOOLCHAIN)size | ||
| 408 | AR = $(TOOLCHAIN)ar | ||
| 409 | NM = $(TOOLCHAIN)nm | ||
| 410 | HEX = $(OBJCOPY) -O $(FORMAT) | ||
| 411 | EEP = | ||
| 412 | BIN = $(OBJCOPY) -O binary | ||
| 323 | 413 | ||
| 324 | MCUFLAGS = -mcpu=$(MCU) | 414 | ############################################################################## |
| 415 | # Make targets | ||
| 416 | # | ||
| 325 | 417 | ||
| 326 | DEBUG = gdb | 418 | DEBUG = gdb |
| 327 | 419 | ||
diff --git a/tmk_core/common/chibios/bootloader.c b/tmk_core/common/chibios/bootloader.c index f9514ee5f..5cadadeee 100644 --- a/tmk_core/common/chibios/bootloader.c +++ b/tmk_core/common/chibios/bootloader.c | |||
| @@ -95,6 +95,28 @@ void enter_bootloader_mode_if_requested(void) { | |||
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | #elif defined(GD32VF103) | ||
| 99 | |||
| 100 | # define DBGMCU_KEY_UNLOCK 0x4B5A6978 | ||
| 101 | # define DBGMCU_CMD_RESET 0x1 | ||
| 102 | |||
| 103 | __IO uint32_t *DBGMCU_KEY = (uint32_t *)DBGMCU_BASE + 0x0CU; | ||
| 104 | __IO uint32_t *DBGMCU_CMD = (uint32_t *)DBGMCU_BASE + 0x08U; | ||
| 105 | |||
| 106 | __attribute__((weak)) void bootloader_jump(void) { | ||
| 107 | /* The MTIMER unit of the GD32VF103 doesn't have the MSFRST | ||
| 108 | * register to generate a software reset request. | ||
| 109 | * BUT instead two undocumented registers in the debug peripheral | ||
| 110 | * that allow issueing a software reset. WHO would need the MSFRST | ||
| 111 | * register anyway? Source: | ||
| 112 | * https://github.com/esmil/gd32vf103inator/blob/master/include/gd32vf103/dbg.h */ | ||
| 113 | *DBGMCU_KEY = DBGMCU_KEY_UNLOCK; | ||
| 114 | *DBGMCU_CMD = DBGMCU_CMD_RESET; | ||
| 115 | } | ||
| 116 | |||
| 117 | void enter_bootloader_mode_if_requested(void) { /* Jumping to bootloader is not possible from user code. */ | ||
| 118 | } | ||
| 119 | |||
| 98 | #elif defined(KL2x) || defined(K20x) || defined(MK66F18) || defined(MIMXRT1062) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS | 120 | #elif defined(KL2x) || defined(K20x) || defined(MK66F18) || defined(MIMXRT1062) // STM32_BOOTLOADER_DUAL_BANK // STM32_BOOTLOADER_ADDRESS |
| 99 | /* Kinetis */ | 121 | /* Kinetis */ |
| 100 | 122 | ||
diff --git a/tmk_core/common/chibios/chibios_config.h b/tmk_core/common/chibios/chibios_config.h index f06594802..ad2f808a9 100644 --- a/tmk_core/common/chibios/chibios_config.h +++ b/tmk_core/common/chibios/chibios_config.h | |||
| @@ -39,6 +39,25 @@ | |||
| 39 | # endif | 39 | # endif |
| 40 | #endif | 40 | #endif |
| 41 | 41 | ||
| 42 | // GD32 compatibility | ||
| 43 | #if defined(MCU_GD32V) | ||
| 44 | # define CPU_CLOCK GD32_SYSCLK | ||
| 45 | |||
| 46 | # if defined(GD32VF103) | ||
| 47 | # define USE_GPIOV1 | ||
| 48 | # define USE_I2CV1 | ||
| 49 | # define PAL_MODE_ALTERNATE_OPENDRAIN PAL_MODE_GD32_ALTERNATE_OPENDRAIN | ||
| 50 | # define PAL_MODE_ALTERNATE_PUSHPULL PAL_MODE_GD32_ALTERNATE_PUSHPULL | ||
| 51 | # endif | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #if defined(GD32VF103) | ||
| 55 | /* This chip has the same API as STM32F103, but uses different names for literally the same thing. | ||
| 56 | * As of 4.7.2021 QMK is tailored to use STM32 defines/names, for compatibility sake | ||
| 57 | * we just redefine the GD32 names. */ | ||
| 58 | # include "gd32v_compatibility.h" | ||
| 59 | #endif | ||
| 60 | |||
| 42 | // teensy compatibility | 61 | // teensy compatibility |
| 43 | #if defined(MCU_KINETIS) | 62 | #if defined(MCU_KINETIS) |
| 44 | # define CPU_CLOCK KINETIS_SYSCLK_FREQUENCY | 63 | # define CPU_CLOCK KINETIS_SYSCLK_FREQUENCY |
diff --git a/tmk_core/common/chibios/eeprom_stm32_defs.h b/tmk_core/common/chibios/eeprom_stm32_defs.h index 349979626..66904f247 100644 --- a/tmk_core/common/chibios/eeprom_stm32_defs.h +++ b/tmk_core/common/chibios/eeprom_stm32_defs.h | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | #include <hal.h> | 18 | #include <hal.h> |
| 19 | 19 | ||
| 20 | #if !defined(FEE_PAGE_SIZE) || !defined(FEE_PAGE_COUNT) | 20 | #if !defined(FEE_PAGE_SIZE) || !defined(FEE_PAGE_COUNT) |
| 21 | # if defined(STM32F103xB) || defined(STM32F042x6) | 21 | # if defined(STM32F103xB) || defined(STM32F042x6) || defined(GD32VF103C8) || defined(GD32VF103CB) |
| 22 | # ifndef FEE_PAGE_SIZE | 22 | # ifndef FEE_PAGE_SIZE |
| 23 | # define FEE_PAGE_SIZE 0x400 // Page size = 1KByte | 23 | # define FEE_PAGE_SIZE 0x400 // Page size = 1KByte |
| 24 | # endif | 24 | # endif |
| @@ -45,7 +45,9 @@ | |||
| 45 | #if !defined(FEE_MCU_FLASH_SIZE) | 45 | #if !defined(FEE_MCU_FLASH_SIZE) |
| 46 | # if defined(STM32F042x6) | 46 | # if defined(STM32F042x6) |
| 47 | # define FEE_MCU_FLASH_SIZE 32 // Size in Kb | 47 | # define FEE_MCU_FLASH_SIZE 32 // Size in Kb |
| 48 | # elif defined(STM32F103xB) || defined(STM32F072xB) || defined(STM32F070xB) | 48 | # elif defined(GD32VF103C8) |
| 49 | # define FEE_MCU_FLASH_SIZE 64 // Size in Kb | ||
| 50 | # elif defined(STM32F103xB) || defined(STM32F072xB) || defined(STM32F070xB) || defined(GD32VF103CB) | ||
| 49 | # define FEE_MCU_FLASH_SIZE 128 // Size in Kb | 51 | # define FEE_MCU_FLASH_SIZE 128 // Size in Kb |
| 50 | # elif defined(STM32F303xC) || defined(STM32F401xC) | 52 | # elif defined(STM32F303xC) || defined(STM32F401xC) |
| 51 | # define FEE_MCU_FLASH_SIZE 256 // Size in Kb | 53 | # define FEE_MCU_FLASH_SIZE 256 // Size in Kb |
diff --git a/tmk_core/common/chibios/flash_stm32.c b/tmk_core/common/chibios/flash_stm32.c index 35fb0eebd..72c41b8b7 100644 --- a/tmk_core/common/chibios/flash_stm32.c +++ b/tmk_core/common/chibios/flash_stm32.c | |||
| @@ -23,6 +23,11 @@ | |||
| 23 | # define FLASH_SR_WRPERR FLASH_SR_WRPRTERR | 23 | # define FLASH_SR_WRPERR FLASH_SR_WRPRTERR |
| 24 | #endif | 24 | #endif |
| 25 | 25 | ||
| 26 | #if defined(MCU_GD32V) | ||
| 27 | /* GigaDevice GD32VF103 is a STM32F103 clone at heart. */ | ||
| 28 | # include "gd32v_compatibility.h" | ||
| 29 | #endif | ||
| 30 | |||
| 26 | #if defined(STM32F4XX) | 31 | #if defined(STM32F4XX) |
| 27 | # define FLASH_SR_PGERR (FLASH_SR_PGSERR | FLASH_SR_PGPERR | FLASH_SR_PGAERR) | 32 | # define FLASH_SR_PGERR (FLASH_SR_PGSERR | FLASH_SR_PGPERR | FLASH_SR_PGAERR) |
| 28 | 33 | ||
diff --git a/tmk_core/common/chibios/gd32v_compatibility.h b/tmk_core/common/chibios/gd32v_compatibility.h new file mode 100644 index 000000000..f4dcfd8c5 --- /dev/null +++ b/tmk_core/common/chibios/gd32v_compatibility.h | |||
| @@ -0,0 +1,120 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | /* GD32VF103 has the same API as STM32F103, but uses different names for literally the same thing. | ||
| 20 | * As of 23.7.2021 QMK is tailored to use STM32 defines/names, for compatibility sake | ||
| 21 | * we just redefine the GD32 names. */ | ||
| 22 | |||
| 23 | /* Close your eyes kids. */ | ||
| 24 | #define MCU_STM32 | ||
| 25 | |||
| 26 | /* AFIO redefines */ | ||
| 27 | #define MAPR PCF0 | ||
| 28 | #define AFIO_MAPR_USART1_REMAP AFIO_PCF0_USART0_REMAP | ||
| 29 | #define AFIO_MAPR_USART2_REMAP AFIO_PCF0_USART1_REMAP | ||
| 30 | #define AFIO_MAPR_USART3_REMAP_PARTIALREMAP AFIO_PCF0_USART2_REMAP_PARTIALREMAP | ||
| 31 | #define AFIO_MAPR_USART3_REMAP_FULLREMAP AFIO_PCF0_USART2_REMAP_FULLREMAP | ||
| 32 | |||
| 33 | /* DMA redefines. */ | ||
| 34 | #define STM32_DMA_STREAM(stream) GD32_DMA_STREAM(stream) | ||
| 35 | #define STM32_DMA_STREAM_ID(peripheral, channel) GD32_DMA_STREAM_ID(peripheral - 1, channel - 1) | ||
| 36 | #define STM32_DMA_CR_DIR_M2P GD32_DMA_CTL_DIR_M2P | ||
| 37 | #define STM32_DMA_CR_PSIZE_WORD GD32_DMA_CTL_PWIDTH_WORD | ||
| 38 | #define STM32_DMA_CR_MSIZE_WORD GD32_DMA_CTL_MWIDTH_WORD | ||
| 39 | #define STM32_DMA_CR_MINC GD32_DMA_CTL_MNAGA | ||
| 40 | #define STM32_DMA_CR_CIRC GD32_DMA_CTL_CMEN | ||
| 41 | #define STM32_DMA_CR_PL GD32_DMA_CTL_PRIO | ||
| 42 | #define STM32_DMA_CR_CHSEL GD32_DMA_CTL_CHSEL | ||
| 43 | #define cr1 ctl0 | ||
| 44 | #define cr2 ctl1 | ||
| 45 | #define cr3 ctl2 | ||
| 46 | #define dier dmainten | ||
| 47 | |||
| 48 | /* ADC redefines */ | ||
| 49 | #if HAL_USE_ADC | ||
| 50 | # define STM32_ADC_USE_ADC1 GD32_ADC_USE_ADC0 | ||
| 51 | |||
| 52 | # define smpr1 sampt0 | ||
| 53 | # define smpr2 sampt1 | ||
| 54 | # define sqr1 rsq0 | ||
| 55 | # define sqr2 rsq1 | ||
| 56 | # define sqr3 rsq2 | ||
| 57 | |||
| 58 | # define ADC_SMPR2_SMP_AN0 ADC_SAMPT1_SMP_SPT0 | ||
| 59 | # define ADC_SMPR2_SMP_AN1 ADC_SAMPT1_SMP_SPT1 | ||
| 60 | # define ADC_SMPR2_SMP_AN2 ADC_SAMPT1_SMP_SPT2 | ||
| 61 | # define ADC_SMPR2_SMP_AN3 ADC_SAMPT1_SMP_SPT3 | ||
| 62 | # define ADC_SMPR2_SMP_AN4 ADC_SAMPT1_SMP_SPT4 | ||
| 63 | # define ADC_SMPR2_SMP_AN5 ADC_SAMPT1_SMP_SPT5 | ||
| 64 | # define ADC_SMPR2_SMP_AN6 ADC_SAMPT1_SMP_SPT6 | ||
| 65 | # define ADC_SMPR2_SMP_AN7 ADC_SAMPT1_SMP_SPT7 | ||
| 66 | # define ADC_SMPR2_SMP_AN8 ADC_SAMPT1_SMP_SPT8 | ||
| 67 | # define ADC_SMPR2_SMP_AN9 ADC_SAMPT1_SMP_SPT9 | ||
| 68 | |||
| 69 | # define ADC_SMPR1_SMP_AN10 ADC_SAMPT0_SMP_SPT10 | ||
| 70 | # define ADC_SMPR1_SMP_AN11 ADC_SAMPT0_SMP_SPT11 | ||
| 71 | # define ADC_SMPR1_SMP_AN12 ADC_SAMPT0_SMP_SPT12 | ||
| 72 | # define ADC_SMPR1_SMP_AN13 ADC_SAMPT0_SMP_SPT13 | ||
| 73 | # define ADC_SMPR1_SMP_AN14 ADC_SAMPT0_SMP_SPT14 | ||
| 74 | # define ADC_SMPR1_SMP_AN15 ADC_SAMPT0_SMP_SPT15 | ||
| 75 | |||
| 76 | # define ADC_SQR3_SQ1_N ADC_RSQ2_RSQ1_N | ||
| 77 | #endif | ||
| 78 | |||
| 79 | /* FLASH redefines */ | ||
| 80 | #if defined(EEPROM_ENABLE) | ||
| 81 | # define SR STAT | ||
| 82 | # define FLASH_SR_BSY FLASH_STAT_BUSY | ||
| 83 | # define FLASH_SR_PGERR FLASH_STAT_PGERR | ||
| 84 | # define FLASH_SR_EOP FLASH_STAT_ENDF | ||
| 85 | # define FLASH_SR_WRPRTERR FLASH_STAT_WPERR | ||
| 86 | # define FLASH_SR_WRPERR FLASH_SR_WRPRTERR | ||
| 87 | # define FLASH_OBR_OPTERR FLASH_OBSTAT_OBERR | ||
| 88 | # define AR ADDR | ||
| 89 | # define CR CTL | ||
| 90 | # define FLASH_CR_PER FLASH_CTL_PER | ||
| 91 | # define FLASH_CR_STRT FLASH_CTL_START | ||
| 92 | # define FLASH_CR_LOCK FLASH_CTL_LK | ||
| 93 | # define FLASH_CR_PG FLASH_CTL_PG | ||
| 94 | # define KEYR KEY | ||
| 95 | #endif | ||
| 96 | |||
| 97 | /* Serial USART redefines. */ | ||
| 98 | #if HAL_USE_SERIAL | ||
| 99 | # if !defined(SERIAL_USART_CR1) | ||
| 100 | # define SERIAL_USART_CR1 (USART_CTL0_PCEN | USART_CTL0_PM | USART_CTL0_WL) // parity enable, odd parity, 9 bit length | ||
| 101 | # endif | ||
| 102 | # if !defined(SERIAL_USART_CR2) | ||
| 103 | # define SERIAL_USART_CR2 (USART_CTL1_STB_1) // 2 stop bits | ||
| 104 | # endif | ||
| 105 | # if !defined(SERIAL_USART_CR3) | ||
| 106 | # define SERIAL_USART_CR3 0x0 | ||
| 107 | # endif | ||
| 108 | # define USART_CR3_HDSEL USART_CTL2_HDEN | ||
| 109 | # define CCR CHCV | ||
| 110 | #endif | ||
| 111 | |||
| 112 | /* SPI redefines. */ | ||
| 113 | #if HAL_USE_SPI | ||
| 114 | # define SPI_CR1_LSBFIRST SPI_CTL0_LF | ||
| 115 | # define SPI_CR1_CPHA SPI_CTL0_CKPH | ||
| 116 | # define SPI_CR1_CPOL SPI_CTL0_CKPL | ||
| 117 | # define SPI_CR1_BR_0 SPI_CTL0_PSC_0 | ||
| 118 | # define SPI_CR1_BR_1 SPI_CTL0_PSC_1 | ||
| 119 | # define SPI_CR1_BR_2 SPI_CTL0_PSC_2 | ||
| 120 | #endif | ||
diff --git a/tmk_core/common/chibios/syscall-fallbacks.c b/tmk_core/common/chibios/syscall-fallbacks.c index 739017ae1..4569879c7 100644 --- a/tmk_core/common/chibios/syscall-fallbacks.c +++ b/tmk_core/common/chibios/syscall-fallbacks.c | |||
| @@ -18,6 +18,12 @@ | |||
| 18 | #include <sys/stat.h> | 18 | #include <sys/stat.h> |
| 19 | #include <sys/types.h> | 19 | #include <sys/types.h> |
| 20 | 20 | ||
| 21 | /* To compile the ChibiOS syscall stubs with picolibc | ||
| 22 | * the _reent struct has to be defined. */ | ||
| 23 | #if defined(USE_PICOLIBC) | ||
| 24 | struct _reent; | ||
| 25 | #endif | ||
| 26 | |||
| 21 | #pragma GCC diagnostic ignored "-Wmissing-prototypes" | 27 | #pragma GCC diagnostic ignored "-Wmissing-prototypes" |
| 22 | 28 | ||
| 23 | __attribute__((weak, used)) int _open_r(struct _reent *r, const char *path, int flag, int m) { | 29 | __attribute__((weak, used)) int _open_r(struct _reent *r, const char *path, int flag, int m) { |
diff --git a/util/install/arch.sh b/util/install/arch.sh index bef98ac37..33c39212d 100755 --- a/util/install/arch.sh +++ b/util/install/arch.sh | |||
| @@ -6,7 +6,8 @@ _qmk_install() { | |||
| 6 | sudo pacman --needed --noconfirm -S \ | 6 | sudo pacman --needed --noconfirm -S \ |
| 7 | base-devel clang diffutils gcc git unzip wget zip python-pip \ | 7 | base-devel clang diffutils gcc git unzip wget zip python-pip \ |
| 8 | avr-binutils arm-none-eabi-binutils arm-none-eabi-gcc \ | 8 | avr-binutils arm-none-eabi-binutils arm-none-eabi-gcc \ |
| 9 | arm-none-eabi-newlib avrdude dfu-programmer dfu-util | 9 | arm-none-eabi-newlib avrdude dfu-programmer dfu-util \ |
| 10 | riscv64-elf-binutils riscv64-elf-gcc riscv64-elf-newlib | ||
| 10 | sudo pacman --needed --noconfirm -U https://archive.archlinux.org/packages/a/avr-gcc/avr-gcc-8.3.0-1-x86_64.pkg.tar.xz | 11 | sudo pacman --needed --noconfirm -U https://archive.archlinux.org/packages/a/avr-gcc/avr-gcc-8.3.0-1-x86_64.pkg.tar.xz |
| 11 | sudo pacman --needed --noconfirm -S avr-libc # Must be installed after the above, or it will bring in the latest avr-gcc instead | 12 | sudo pacman --needed --noconfirm -S avr-libc # Must be installed after the above, or it will bring in the latest avr-gcc instead |
| 12 | 13 | ||
diff --git a/util/install/debian.sh b/util/install/debian.sh index 57588e371..2a188334b 100755 --- a/util/install/debian.sh +++ b/util/install/debian.sh | |||
| @@ -15,7 +15,8 @@ _qmk_install() { | |||
| 15 | build-essential clang-format diffutils gcc git unzip wget zip \ | 15 | build-essential clang-format diffutils gcc git unzip wget zip \ |
| 16 | python3-pip binutils-avr gcc-avr avr-libc binutils-arm-none-eabi \ | 16 | python3-pip binutils-avr gcc-avr avr-libc binutils-arm-none-eabi \ |
| 17 | gcc-arm-none-eabi libnewlib-arm-none-eabi avrdude dfu-programmer \ | 17 | gcc-arm-none-eabi libnewlib-arm-none-eabi avrdude dfu-programmer \ |
| 18 | dfu-util teensy-loader-cli libhidapi-hidraw0 libusb-dev | 18 | dfu-util teensy-loader-cli libhidapi-hidraw0 libusb-dev \ |
| 19 | picolibc-riscv64-unknown-elf gcc-riscv64-unknown-elf binutils-riscv64-unknown-elf | ||
| 19 | 20 | ||
| 20 | python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt | 21 | python3 -m pip install --user -r $QMK_FIRMWARE_DIR/requirements.txt |
| 21 | } | 22 | } |
