diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index d3a26923b541..59aae47ec8cc 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -112,6 +112,7 @@ "atmega328p", "atmega328", "attiny85", + "risc-v", "unknown" ] }, diff --git a/docs/compatible_microcontrollers.md b/docs/compatible_microcontrollers.md index f148c39191e1..f1ed71355ae5 100644 --- a/docs/compatible_microcontrollers.md +++ b/docs/compatible_microcontrollers.md @@ -61,6 +61,10 @@ You can also use any ARM chip with USB that [ChibiOS](https://www.chibios.org) s * [AT32F415](https://www.arterychip.com/en/product/AT32F415.jsp) +### essemi (ES32) + + * [ES32VF2264](https://www.essemi.com/index/product/detail?id=969) + ### NXP (Kinetis) * [MKL26Z64](https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/kl-series-cortex-m0-plus/kinetis-kl2x-72-96-mhz-usb-ultra-low-power-microcontrollers-mcus-based-on-arm-cortex-m0-plus-core:KL2x) diff --git a/keyboards/handwired/onekey/essemi_es32vf2264/board.h b/keyboards/handwired/onekey/essemi_es32vf2264/board.h new file mode 100644 index 000000000000..8b40c29d8656 --- /dev/null +++ b/keyboards/handwired/onekey/essemi_es32vf2264/board.h @@ -0,0 +1,8 @@ +// Copyright 2023-2024 HorrorTroll +// Copyright 2023-2024 Zhaqian +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + diff --git a/keyboards/handwired/onekey/essemi_es32vf2264/config.h b/keyboards/handwired/onekey/essemi_es32vf2264/config.h new file mode 100644 index 000000000000..39cac714f745 --- /dev/null +++ b/keyboards/handwired/onekey/essemi_es32vf2264/config.h @@ -0,0 +1,44 @@ +// Copyright 2023-2024 HorrorTroll +// Copyright 2023-2024 Zhaqian +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +/* ADC configs */ +#define ADC_PIN C5 +#define ADC_USE_ADC1 + +/* SPI configs */ +#define SPI_DRIVER SPID1 +#define SPI_SCK_PIN A5 +#define SPI_MOSI_PIN A7 +#define SPI_MISO_PIN A6 + +/* I2C configs */ +#define USE_I2CV1_CONTRIB +#define I2C_DRIVER I2CD1 +#define I2C1_SDA_PIN B7 +#define I2C1_SCL_PIN B6 +#define I2C1_SCL_PAL_MODE 4 +#define I2C1_OPMODE OPMODE_I2C +#define I2C1_CLOCK_SPEED 100000 + +/* Apa102 configs */ +#define APA102_NOPS (100 / (1000000000L / (CPU_CLOCK / 4))) + +/* Haptic configs */ +#define SOLENOID_PIN B12 +#define SOLENOID_PINS { B12, B13, B14, B15 } +#define SOLENOID_PINS_ACTIVE_STATE { high, high, low } + +/* Backlight configs */ +#define BACKLIGHT_PWM_DRIVER PWM_GP16C4T1 +#define BACKLIGHT_PWM_CHANNEL 3 + +/* LCD configs */ +#define LCD_RST_PIN A2 +#define LCD_DC_PIN A3 +#define LCD_CS_PIN A4 + +// Bitbang WS2812 +#define WS2812_BITBANG_NOP_FUDGE 0.4 diff --git a/keyboards/handwired/onekey/essemi_es32vf2264/halconf.h b/keyboards/handwired/onekey/essemi_es32vf2264/halconf.h new file mode 100644 index 000000000000..8411987e85f3 --- /dev/null +++ b/keyboards/handwired/onekey/essemi_es32vf2264/halconf.h @@ -0,0 +1,12 @@ +// Copyright 2023-2024 HorrorTroll +// Copyright 2023-2024 Zhaqian +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define HAL_USE_ADC TRUE +#define HAL_USE_I2C TRUE +#define HAL_USE_SPI TRUE +#define HAL_USE_PWM TRUE + +#include_next diff --git a/keyboards/handwired/onekey/essemi_es32vf2264/keyboard.json b/keyboards/handwired/onekey/essemi_es32vf2264/keyboard.json new file mode 100644 index 000000000000..1d124ed0c87d --- /dev/null +++ b/keyboards/handwired/onekey/essemi_es32vf2264/keyboard.json @@ -0,0 +1,23 @@ +{ + "keyboard_name": "Onekey essemi_fs026", + "bootloader": "custom", + "usb": { + "shared_endpoint": { + "keyboard": true + } + }, + "matrix_pins": { + "cols": ["D15"], + "rows": ["B0"] + }, + "backlight": { + "pin": "A5" + }, + "ws2812": { + "pin": "C0" + }, + "apa102": { + "data_pin": "B10", + "clock_pin": "B11" + } +} diff --git a/keyboards/handwired/onekey/essemi_es32vf2264/mcuconf.h b/keyboards/handwired/onekey/essemi_es32vf2264/mcuconf.h new file mode 100644 index 000000000000..eaf3aa78fb84 --- /dev/null +++ b/keyboards/handwired/onekey/essemi_es32vf2264/mcuconf.h @@ -0,0 +1,95 @@ +/* + Copyright (C) 2021 essemi + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef MCUCONF_H +#define MCUCONF_H + +#define ES32_ES32VF2264_MCUCONF + +/* + * HAL driver system settings. + */ +#define ES32_NO_INIT FALSE + +/* + * GPIO driver system settings. + */ +#define ES32_USB_USE_GPIO TRUE + +/* + * ADC driver system settings. + */ +#define ES32_ADC_USE_ADC1 TRUE + +/* + * GPT driver system settings. + */ +#define ES32_GPT_USE_GP16C4T1 TRUE +#define ES32_GPT_USE_GP16C4T2 FALSE + +/* + * ICU driver system settings. + */ +#define ES32_ICU_USE_GP16C4T1 FALSE +#define ES32_ICU_USE_GP16C4T2 FALSE + +/* + * I2C driver system settings. + */ +#define ES32_I2C_USE_I2C1 TRUE +#define ES32_I2C_USE_I2C2 FALSE +#define ES32_I2C_BUSY_TIMEOUT 50 + +/* + * SERIAL driver system settings. + */ +#define ES32_SERIAL_USE_UART1 FALSE +#define ES32_SERIAL_USE_UART2 FALSE +#define ES32_SERIAL_USE_UART3 FALSE +#define ES32_SERIAL_USE_UART4 FALSE + +/* + * SPI driver system settings. + */ +#define ES32_SPI_USE_SPI1 TRUE +#define ES32_SPI_USE_SPI2 FALSE + +/* + * ST driver system settings. + */ +#define ES32_ST_USE_TIMER 2 + +/* + * UART driver system settings. + */ +#define ES32_UART_USE_UART1 FALSE +#define ES32_UART_USE_UART2 FALSE +#define ES32_UART_USE_UART3 FALSE +#define ES32_UART_USE_UART4 FALSE + +/* + * PWM driver system settings. + */ +#define ES32_PWM_USE_GP16C4T1 TRUE +#define ES32_PWM_USE_GP16C4T2 FALSE + +/* + * USB driver system settings. + */ +#define ES32_USB_USE_USB1 TRUE +#define ES32_USE_USB_SOF_TRIM_HRC48 TRUE + +#endif /* MCUCONF_H */ diff --git a/keyboards/handwired/onekey/essemi_es32vf2264/readme.md b/keyboards/handwired/onekey/essemi_es32vf2264/readme.md new file mode 100644 index 000000000000..1b18c3d71437 --- /dev/null +++ b/keyboards/handwired/onekey/essemi_es32vf2264/readme.md @@ -0,0 +1,3 @@ +# essemi ES-PDS-ES32VF2264 Board Onekey + +To trigger keypress, short together pins *D15* and *B0*. diff --git a/keyboards/handwired/onekey/essemi_es32vf2264/rules.mk b/keyboards/handwired/onekey/essemi_es32vf2264/rules.mk new file mode 100644 index 000000000000..09a6b276a5db --- /dev/null +++ b/keyboards/handwired/onekey/essemi_es32vf2264/rules.mk @@ -0,0 +1,31 @@ +# RISC-V +MCU = risc-v + +# RISC-V extensions and abi configuration +MCU_ARCH = rv32emc +MCU_ABI = ilp32e +MCU_CMODEL = medlow + +## chip/board settings +# - the next two should match the directories in +# /os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES) +# OR +# /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) +MCU_PORT_NAME = ES32 +MCU_FAMILY = ES32 +MCU_SERIES = ES32VF2264 + +# Linker script to use +# - it should exist either in /os/common/startup/RISCV-CLIC/compilers/GCC/ld/ +# or /ld/ +MCU_LDSCRIPT ?= ES32VF2264 + +# Startup code to use +# - it should exist in /os/common/startup/RISCV-CLIC/compilers/GCC/mk/ +MCU_STARTUP ?= es32vf2264 + +# Board: it should exist either in /os/hal/boards/, +# /boards/, or drivers/boards/ +BOARD ?= ES32VF2264 + +USE_FPU ?= no \ No newline at end of file diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py index e3e47c2bd280..634ba80be8f7 100644 --- a/lib/python/qmk/constants.py +++ b/lib/python/qmk/constants.py @@ -22,7 +22,7 @@ MAX_KEYBOARD_SUBFOLDERS = 5 # Supported processor types -CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK64FX512', 'MK66FX1M0', 'RP2040', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F405', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G0B1', 'STM32G431', 'STM32G474', 'STM32H723', 'STM32H733', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95', 'AT32F415' +CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK64FX512', 'MK66FX1M0', 'RP2040', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F405', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G0B1', 'STM32G431', 'STM32G474', 'STM32H723', 'STM32H733', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95', 'AT32F415','risc-v' LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85' diff --git a/platforms/chibios/drivers/analog.c b/platforms/chibios/drivers/analog.c index 93005c2555ee..450fc196ceef 100644 --- a/platforms/chibios/drivers/analog.c +++ b/platforms/chibios/drivers/analog.c @@ -22,7 +22,7 @@ # error "You need to set HAL_USE_ADC to TRUE in your halconf.h to use the ADC." #endif -#if !RP_ADC_USE_ADC1 && !STM32_ADC_USE_ADC1 && !STM32_ADC_USE_ADC2 && !STM32_ADC_USE_ADC3 && !STM32_ADC_USE_ADC4 && !WB32_ADC_USE_ADC1 && !AT32_ADC_USE_ADC1 +#if !RP_ADC_USE_ADC1 && !STM32_ADC_USE_ADC1 && !STM32_ADC_USE_ADC2 && !STM32_ADC_USE_ADC3 && !STM32_ADC_USE_ADC4 && !WB32_ADC_USE_ADC1 && !AT32_ADC_USE_ADC1 && !ES32_ADC_USE_ADC1 # error "You need to set one of the 'xxx_ADC_USE_ADCx' settings to TRUE in your mcuconf.h to use the ADC." #endif diff --git a/platforms/chibios/platform.mk b/platforms/chibios/platform.mk index cf9fac251e45..4e0d24767c7b 100644 --- a/platforms/chibios/platform.mk +++ b/platforms/chibios/platform.mk @@ -40,6 +40,14 @@ ifeq ($(strip $(MCU)), risc-v) STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/RISCV-ECLIC/compilers/GCC/mk/startup_$(MCU_STARTUP).mk PORT_V = $(CHIBIOS_CONTRIB)/os/common/ports/RISCV-ECLIC/compilers/GCC/mk/port.mk RULESPATH = $(CHIBIOS_CONTRIB)/os/common/startup/RISCV-ECLIC/compilers/GCC + + # RISC-V CLIC: Standardized Core Local Interrupt Controller + # RISC-V ECLIC: Enhanced Core Local Interrupt Controller (Vendor-specific Implementation) + ifeq ("$(wildcard $(STARTUP_MK))","") + STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/RISCV-CLIC/compilers/GCC/mk/startup_$(MCU_STARTUP).mk + PORT_V = $(CHIBIOS_CONTRIB)/os/common/ports/RISCV-CLIC/compilers/GCC/mk/port.mk + RULESPATH = $(CHIBIOS_CONTRIB)/os/common/startup/RISCV-CLIC/compilers/GCC + endif else # ARM Support CHIBIOS_PORT ?=