From ec0533e2be09cd4ccb134db366ef41a34b405bc6 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 12 Jun 2024 23:13:17 +0300 Subject: [PATCH 01/16] sn32: add sn32f290 to schemas --- data/schemas/keyboard.jsonschema | 1 + lib/python/qmk/constants.py | 3 ++- platforms/chibios/mcu_selection.mk | 32 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 417a1a0960f3..a9a78acda63c 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -73,6 +73,7 @@ "SN32F248F", "SN32F248BF", "SN32F268F", + "SN32F299F", "STM32F042", "STM32F072", "STM32F103", diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py index 4a13942ef175..4e03db780a14 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', 'STM32G431', 'STM32G474', 'STM32H723', 'STM32H733', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95', 'SN32F248F', 'SN32F248BF', 'SN32F268F' +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', 'STM32G431', 'STM32G474', 'STM32H723', 'STM32H733', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95', 'SN32F248F', 'SN32F248BF', 'SN32F268F', 'SN32F299F' LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85' @@ -58,6 +58,7 @@ "SN32F248F": "sn32-dfu", "SN32F248BF": "sn32-dfu", "SN32F268F": "sn32-dfu", + "SN32F299F": "sn32-dfu", "atmega16u2": "atmel-dfu", "atmega32u2": "atmel-dfu", "atmega16u4": "atmel-dfu", diff --git a/platforms/chibios/mcu_selection.mk b/platforms/chibios/mcu_selection.mk index 6ebc402bbf8a..cfd73917c084 100644 --- a/platforms/chibios/mcu_selection.mk +++ b/platforms/chibios/mcu_selection.mk @@ -953,3 +953,35 @@ ifneq ($(findstring SN32F268F, $(MCU)),) # Bootloader address for SN32 DFU SN32_BOOTLOADER_ADDRESS = 0x1FFF0009 endif + +ifneq ($(findstring SN32F299F, $(MCU)),) + # Cortex version + MCU = cortex-m0 + + # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7 + ARMV = 6 + + ## chip/board settings + # - the next two should match the directories in + # /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) + MCU_FAMILY = SN32 + MCU_SERIES = SN32F290 + + # Linker script to use + # - it should exist either in /os/common/ports/ARMCMx/compilers/GCC/ld/ + # or /ld/ + MCU_LDSCRIPT ?= SN32F290 + + # Startup code to use + # - it should exist in /os/common/startup/ARMCMx/compilers/GCC/mk/ + MCU_STARTUP ?= sn32f29x + + # Board: it should exist either in /os/hal/boards/, + # /boards/, or drivers/boards/ + BOARD ?= SN_SN32F290 + + USE_FPU ?= no + + # Bootloader address for SN32 DFU + SN32_BOOTLOADER_ADDRESS = 0x1FFF0009 +endif From 38e00fb4a6fe7bfcabc7abc4f50f06c8e3911f68 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 12 Jun 2024 23:14:15 +0300 Subject: [PATCH 02/16] sn32: add sn32f290 onekey --- keyboards/handwired/onekey/sn32f290/config.h | 24 +++++++++++++++++++ keyboards/handwired/onekey/sn32f290/info.json | 9 +++++++ keyboards/handwired/onekey/sn32f290/mcuconf.h | 19 +++++++++++++++ keyboards/handwired/onekey/sn32f290/readme.md | 5 ++++ 4 files changed, 57 insertions(+) create mode 100644 keyboards/handwired/onekey/sn32f290/config.h create mode 100644 keyboards/handwired/onekey/sn32f290/info.json create mode 100644 keyboards/handwired/onekey/sn32f290/mcuconf.h create mode 100644 keyboards/handwired/onekey/sn32f290/readme.md diff --git a/keyboards/handwired/onekey/sn32f290/config.h b/keyboards/handwired/onekey/sn32f290/config.h new file mode 100644 index 000000000000..22af1955aa2c --- /dev/null +++ b/keyboards/handwired/onekey/sn32f290/config.h @@ -0,0 +1,24 @@ +/* Copyright 2024 Dimitris Mantzouranis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +/* +#define I2C_DRIVER I2CD0 +#define I2C1_SCL_PIN A6 +#define I2C1_SDA_PIN A7 +#define I2C1_OPMODE OPMODE_I2C +#define I2C1_CLOCK_SPEED 400000 +*/ \ No newline at end of file diff --git a/keyboards/handwired/onekey/sn32f290/info.json b/keyboards/handwired/onekey/sn32f290/info.json new file mode 100644 index 000000000000..b8fbe8b6bfea --- /dev/null +++ b/keyboards/handwired/onekey/sn32f290/info.json @@ -0,0 +1,9 @@ +{ + "keyboard_name": "Onekey SN32F290", + "processor": "SN32F299F", + "bootloader": "sn32-dfu", + "matrix_pins": { + "cols": ["A8"], + "rows": ["D11"] + } +} diff --git a/keyboards/handwired/onekey/sn32f290/mcuconf.h b/keyboards/handwired/onekey/sn32f290/mcuconf.h new file mode 100644 index 000000000000..d8556da7b69c --- /dev/null +++ b/keyboards/handwired/onekey/sn32f290/mcuconf.h @@ -0,0 +1,19 @@ +/* Copyright 2024 Dimitris Mantzouranis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +//#define SN32_I2C_USE_I2C0 TRUE +#include_next diff --git a/keyboards/handwired/onekey/sn32f290/readme.md b/keyboards/handwired/onekey/sn32f290/readme.md new file mode 100644 index 000000000000..63d80fc4cdcc --- /dev/null +++ b/keyboards/handwired/onekey/sn32f290/readme.md @@ -0,0 +1,5 @@ +# SN32F290 onekey + +Supported Hardware: *SN32F290*. + +To trigger keypress, short together pins *A8* and *D11*. From 5eaa84c1a84be691dffebca4d69885ebc37711ce Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 12 Jun 2024 23:15:12 +0300 Subject: [PATCH 03/16] sn32: add sn32f290 board --- .../chibios/boards/SN_SN32F290/board/board.mk | 16 ++++++++ .../boards/SN_SN32F290/configs/chconf.h | 38 +++++++++++++++++++ .../boards/SN_SN32F290/configs/config.h | 24 ++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 platforms/chibios/boards/SN_SN32F290/board/board.mk create mode 100644 platforms/chibios/boards/SN_SN32F290/configs/chconf.h create mode 100644 platforms/chibios/boards/SN_SN32F290/configs/config.h diff --git a/platforms/chibios/boards/SN_SN32F290/board/board.mk b/platforms/chibios/boards/SN_SN32F290/board/board.mk new file mode 100644 index 000000000000..2f122ccdf2d5 --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F290/board/board.mk @@ -0,0 +1,16 @@ +# List of all the board related files. +BOARDSRC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F290/board.c + +# Required include directories +BOARDINC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F290 + +# Optimize for speed +OPT = 2 +# Enter lower-power sleep mode when on the ChibiOS idle thread +OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE +# Shave some extra bytes +OPT_DEFS += -DCRT1_AREAS_NUMBER=1 + +# Shared variables +ALLCSRC += $(BOARDSRC) +ALLINC += $(BOARDINC) diff --git a/platforms/chibios/boards/SN_SN32F290/configs/chconf.h b/platforms/chibios/boards/SN_SN32F290/configs/chconf.h new file mode 100644 index 000000000000..ea57a2ca2271 --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F290/configs/chconf.h @@ -0,0 +1,38 @@ +/* Copyright 2024 Dimitris Mantzouranis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* + * This file was auto-generated by: + * `qmk chibios-confmigrate -i platforms/chibios/boards/SN_SN32F240B/configs/chconf.h -r platforms/chibios/boards/common/configs/chconf.h` + */ + +#pragma once + +#define CH_CFG_ST_RESOLUTION 16 + +#define CH_CFG_ST_FREQUENCY 187500 + +#include_next + +#undef CH_CFG_IDLE_ENTER_HOOK +#define CH_CFG_IDLE_ENTER_HOOK() { \ + SN_PMU->CTRL = 4; \ +} + +#undef CH_CFG_IDLE_LEAVE_HOOK +#define CH_CFG_IDLE_LEAVE_HOOK() { \ + SN_PMU->CTRL = 0; \ +} diff --git a/platforms/chibios/boards/SN_SN32F290/configs/config.h b/platforms/chibios/boards/SN_SN32F290/configs/config.h new file mode 100644 index 000000000000..efdfd59387d7 --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F290/configs/config.h @@ -0,0 +1,24 @@ +/* Copyright 2024 Dimitris Mantzouranis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP +# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE +#endif + +#ifndef WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT +# define WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT 1 +#endif \ No newline at end of file From 121d441beb276ece590f23f5d4fbd08f04a43f4d Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Thu, 12 Dec 2024 22:54:34 +0200 Subject: [PATCH 04/16] sn32: add sn32f290 usb pids --- lib/python/qmk/constants.py | 3 ++- util/udev/50-qmk.rules | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py index 4e03db780a14..3580560a91a2 100644 --- a/lib/python/qmk/constants.py +++ b/lib/python/qmk/constants.py @@ -128,7 +128,8 @@ 'sn32-dfu': { ("0c45", "7010"), # SN32F260 ("0c45", "7040"), # SN32F240B - ("0c45", "7900") # SN32F240 + ("0c45", "7900"), # SN32F240 + ("0c45", "7140") # SN32F290 } } diff --git a/util/udev/50-qmk.rules b/util/udev/50-qmk.rules index cc7bb7544398..d5011d02bb87 100644 --- a/util/udev/50-qmk.rules +++ b/util/udev/50-qmk.rules @@ -89,3 +89,4 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="342d", ATTRS{idProduct}=="dfa0", TAG+="uacc SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7010", TAG+="uaccess" SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7040", TAG+="uaccess" SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7900", TAG+="uaccess" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7140", TAG+="uaccess" From 332e3d7118a373aba9b497c1c6a8f402312c5819 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Thu, 12 Dec 2024 23:22:17 +0200 Subject: [PATCH 05/16] sn32: add sn32f240c to schemas --- data/schemas/keyboard.jsonschema | 1 + lib/python/qmk/constants.py | 4 +++- platforms/chibios/mcu_selection.mk | 32 ++++++++++++++++++++++++++++++ util/udev/50-qmk.rules | 1 + 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index a9a78acda63c..33f732c494ae 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -72,6 +72,7 @@ "RP2040", "SN32F248F", "SN32F248BF", + "SN32F248CF", "SN32F268F", "SN32F299F", "STM32F042", diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py index 3580560a91a2..127f7d09fd22 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', 'STM32G431', 'STM32G474', 'STM32H723', 'STM32H733', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95', 'SN32F248F', 'SN32F248BF', 'SN32F268F', 'SN32F299F' +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', 'STM32G431', 'STM32G474', 'STM32H723', 'STM32H733', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95', 'SN32F248F', 'SN32F248BF', 'SN32F248CF', 'SN32F268F', 'SN32F299F' LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85' @@ -57,6 +57,7 @@ "WB32FQ95": "wb32-dfu", "SN32F248F": "sn32-dfu", "SN32F248BF": "sn32-dfu", + "SN32F248CF": "sn32-dfu", "SN32F268F": "sn32-dfu", "SN32F299F": "sn32-dfu", "atmega16u2": "atmel-dfu", @@ -128,6 +129,7 @@ 'sn32-dfu': { ("0c45", "7010"), # SN32F260 ("0c45", "7040"), # SN32F240B + ("0c45", "7160"), # SN32F240C ("0c45", "7900"), # SN32F240 ("0c45", "7140") # SN32F290 } diff --git a/platforms/chibios/mcu_selection.mk b/platforms/chibios/mcu_selection.mk index cfd73917c084..5d78b77b8c53 100644 --- a/platforms/chibios/mcu_selection.mk +++ b/platforms/chibios/mcu_selection.mk @@ -917,6 +917,38 @@ ifneq ($(findstring SN32F248BF, $(MCU)),) SN32_BOOTLOADER_ADDRESS = 0x1FFF0301 endif +ifneq ($(findstring SN32F248CF, $(MCU)),) + # Cortex version + MCU = cortex-m0 + + # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7 + ARMV = 6 + + ## chip/board settings + # - the next two should match the directories in + # /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) + MCU_FAMILY = SN32 + MCU_SERIES = SN32F240C + + # Linker script to use + # - it should exist either in /os/common/ports/ARMCMx/compilers/GCC/ld/ + # or /ld/ + MCU_LDSCRIPT ?= SN32F240C + + # Startup code to use + # - it should exist in /os/common/startup/ARMCMx/compilers/GCC/mk/ + MCU_STARTUP ?= sn32f24xc + + # Board: it should exist either in /os/hal/boards/, + # /boards/, or drivers/boards/ + BOARD ?= SN_SN32F240C + + USE_FPU ?= no + + # Bootloader address for SN32 DFU + SN32_BOOTLOADER_ADDRESS = 0x1FFF0301 +endif + ifneq ($(findstring SN32F268F, $(MCU)),) # Cortex version MCU = cortex-m0 diff --git a/util/udev/50-qmk.rules b/util/udev/50-qmk.rules index d5011d02bb87..23f03dad7ddf 100644 --- a/util/udev/50-qmk.rules +++ b/util/udev/50-qmk.rules @@ -90,3 +90,4 @@ SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7010", TAG+="uacc SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7040", TAG+="uaccess" SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7900", TAG+="uaccess" SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7140", TAG+="uaccess" +SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7160", TAG+="uaccess" From 9ad7912f901a208db0da5cc96accc0f41e92888e Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Thu, 12 Dec 2024 23:28:21 +0200 Subject: [PATCH 06/16] sn32: add sn32f240c onekey --- keyboards/handwired/onekey/sn32f240c/config.h | 24 +++++++++++++++++++ .../handwired/onekey/sn32f240c/info.json | 9 +++++++ .../handwired/onekey/sn32f240c/mcuconf.h | 19 +++++++++++++++ .../handwired/onekey/sn32f240c/readme.md | 5 ++++ 4 files changed, 57 insertions(+) create mode 100644 keyboards/handwired/onekey/sn32f240c/config.h create mode 100644 keyboards/handwired/onekey/sn32f240c/info.json create mode 100644 keyboards/handwired/onekey/sn32f240c/mcuconf.h create mode 100644 keyboards/handwired/onekey/sn32f240c/readme.md diff --git a/keyboards/handwired/onekey/sn32f240c/config.h b/keyboards/handwired/onekey/sn32f240c/config.h new file mode 100644 index 000000000000..22af1955aa2c --- /dev/null +++ b/keyboards/handwired/onekey/sn32f240c/config.h @@ -0,0 +1,24 @@ +/* Copyright 2024 Dimitris Mantzouranis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once +/* +#define I2C_DRIVER I2CD0 +#define I2C1_SCL_PIN A6 +#define I2C1_SDA_PIN A7 +#define I2C1_OPMODE OPMODE_I2C +#define I2C1_CLOCK_SPEED 400000 +*/ \ No newline at end of file diff --git a/keyboards/handwired/onekey/sn32f240c/info.json b/keyboards/handwired/onekey/sn32f240c/info.json new file mode 100644 index 000000000000..d0eaa0ce636f --- /dev/null +++ b/keyboards/handwired/onekey/sn32f240c/info.json @@ -0,0 +1,9 @@ +{ + "keyboard_name": "Onekey SN32F240C", + "processor": "SN32F248CF", + "bootloader": "sn32-dfu", + "matrix_pins": { + "cols": ["A8"], + "rows": ["D11"] + } +} diff --git a/keyboards/handwired/onekey/sn32f240c/mcuconf.h b/keyboards/handwired/onekey/sn32f240c/mcuconf.h new file mode 100644 index 000000000000..d8556da7b69c --- /dev/null +++ b/keyboards/handwired/onekey/sn32f240c/mcuconf.h @@ -0,0 +1,19 @@ +/* Copyright 2024 Dimitris Mantzouranis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +//#define SN32_I2C_USE_I2C0 TRUE +#include_next diff --git a/keyboards/handwired/onekey/sn32f240c/readme.md b/keyboards/handwired/onekey/sn32f240c/readme.md new file mode 100644 index 000000000000..ec6ab40c2687 --- /dev/null +++ b/keyboards/handwired/onekey/sn32f240c/readme.md @@ -0,0 +1,5 @@ +# SN32F240C onekey + +Supported Hardware: *SN32F240C*. + +To trigger keypress, short together pins *A8* and *D11*. From 9df433d9cd4e7cfa1d4384f4d7a9e6273135a056 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Thu, 12 Dec 2024 23:34:25 +0200 Subject: [PATCH 07/16] sn32: add sn32f240c to boards --- .../boards/SN_SN32F240C/board/board.mk | 16 ++++++++ .../boards/SN_SN32F240C/configs/chconf.h | 38 +++++++++++++++++++ .../boards/SN_SN32F240C/configs/config.h | 24 ++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 platforms/chibios/boards/SN_SN32F240C/board/board.mk create mode 100644 platforms/chibios/boards/SN_SN32F240C/configs/chconf.h create mode 100644 platforms/chibios/boards/SN_SN32F240C/configs/config.h diff --git a/platforms/chibios/boards/SN_SN32F240C/board/board.mk b/platforms/chibios/boards/SN_SN32F240C/board/board.mk new file mode 100644 index 000000000000..d71b2eb4e24c --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F240C/board/board.mk @@ -0,0 +1,16 @@ +# List of all the board related files. +BOARDSRC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240C/board.c + +# Required include directories +BOARDINC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240C + +# Optimize for speed +OPT = 2 +# Enter lower-power sleep mode when on the ChibiOS idle thread +OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE +# Shave some extra bytes +OPT_DEFS += -DCRT1_AREAS_NUMBER=1 + +# Shared variables +ALLCSRC += $(BOARDSRC) +ALLINC += $(BOARDINC) diff --git a/platforms/chibios/boards/SN_SN32F240C/configs/chconf.h b/platforms/chibios/boards/SN_SN32F240C/configs/chconf.h new file mode 100644 index 000000000000..9ddf788a20c0 --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F240C/configs/chconf.h @@ -0,0 +1,38 @@ +/* Copyright 2020 QMK + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* + * This file was auto-generated by: + * `qmk chibios-confmigrate -i platforms/chibios/boards/SN_SN32F240C/configs/chconf.h -r platforms/chibios/boards/common/configs/chconf.h` + */ + +#pragma once + +#define CH_CFG_ST_RESOLUTION 16 + +#define CH_CFG_ST_FREQUENCY 187500 + +#include_next + +#undef CH_CFG_IDLE_ENTER_HOOK +#define CH_CFG_IDLE_ENTER_HOOK() { \ + SN_PMU->CTRL = 4; \ +} + +#undef CH_CFG_IDLE_LEAVE_HOOK +#define CH_CFG_IDLE_LEAVE_HOOK() { \ + SN_PMU->CTRL = 0; \ +} diff --git a/platforms/chibios/boards/SN_SN32F240C/configs/config.h b/platforms/chibios/boards/SN_SN32F240C/configs/config.h new file mode 100644 index 000000000000..efdfd59387d7 --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F240C/configs/config.h @@ -0,0 +1,24 @@ +/* Copyright 2024 Dimitris Mantzouranis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once + +#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP +# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE +#endif + +#ifndef WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT +# define WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT 1 +#endif \ No newline at end of file From 287047222e7dff821adc3e93ec41eaf33582d2af Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Thu, 12 Dec 2024 23:40:16 +0200 Subject: [PATCH 08/16] sn32: add sn32f240c to bootloaders --- platforms/chibios/bootloader.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platforms/chibios/bootloader.mk b/platforms/chibios/bootloader.mk index e8b9ec94f4ef..ff8f16653a2d 100644 --- a/platforms/chibios/bootloader.mk +++ b/platforms/chibios/bootloader.mk @@ -131,6 +131,9 @@ ifeq ($(strip $(BOOTLOADER)), sn32-dfu) ifeq ($(strip $(MCU_SERIES)), SN32F240B) DFU_ARGS ?= -v 0c45/7040 endif + ifeq ($(strip $(MCU_SERIES)), SN32F240C) + DFU_ARGS ?= -v 0c45/7160 + endif ifeq ($(strip $(MCU_SERIES)), SN32F260) DFU_ARGS ?= -v 0c45/7010 -o 0x200 endif From 6d4322bf020acb064ed256d251a1578d8e68c2e3 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Thu, 12 Dec 2024 23:41:07 +0200 Subject: [PATCH 09/16] sn32: add sn32f290 to bootloaders --- platforms/chibios/bootloader.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/platforms/chibios/bootloader.mk b/platforms/chibios/bootloader.mk index ff8f16653a2d..b44cb7d66275 100644 --- a/platforms/chibios/bootloader.mk +++ b/platforms/chibios/bootloader.mk @@ -137,6 +137,9 @@ ifeq ($(strip $(BOOTLOADER)), sn32-dfu) ifeq ($(strip $(MCU_SERIES)), SN32F260) DFU_ARGS ?= -v 0c45/7010 -o 0x200 endif + ifeq ($(strip $(MCU_SERIES)), SN32F290) + DFU_ARGS ?= -v 0c45/7140 + endif endif From aa5ca85eb973052aeec1373de11532985753d6cb Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Fri, 13 Dec 2024 12:42:08 +0200 Subject: [PATCH 10/16] sn32: 240c/290: fix onekey build --- keyboards/handwired/onekey/sn32f240c/keyboard.json | 9 +++++++++ keyboards/handwired/onekey/sn32f290/keyboard.json | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 keyboards/handwired/onekey/sn32f240c/keyboard.json create mode 100644 keyboards/handwired/onekey/sn32f290/keyboard.json diff --git a/keyboards/handwired/onekey/sn32f240c/keyboard.json b/keyboards/handwired/onekey/sn32f240c/keyboard.json new file mode 100644 index 000000000000..d0eaa0ce636f --- /dev/null +++ b/keyboards/handwired/onekey/sn32f240c/keyboard.json @@ -0,0 +1,9 @@ +{ + "keyboard_name": "Onekey SN32F240C", + "processor": "SN32F248CF", + "bootloader": "sn32-dfu", + "matrix_pins": { + "cols": ["A8"], + "rows": ["D11"] + } +} diff --git a/keyboards/handwired/onekey/sn32f290/keyboard.json b/keyboards/handwired/onekey/sn32f290/keyboard.json new file mode 100644 index 000000000000..b8fbe8b6bfea --- /dev/null +++ b/keyboards/handwired/onekey/sn32f290/keyboard.json @@ -0,0 +1,9 @@ +{ + "keyboard_name": "Onekey SN32F290", + "processor": "SN32F299F", + "bootloader": "sn32-dfu", + "matrix_pins": { + "cols": ["A8"], + "rows": ["D11"] + } +} From 313223c7f5b0fce8f2c711c8c3e83e4e16a3383f Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 18 Dec 2024 12:18:14 +0200 Subject: [PATCH 11/16] sn32: update default mcuconf.h for all chips --- .../boards/SN_SN32F240B/configs/mcuconf.h | 69 +++++++++++++++++++ .../boards/SN_SN32F240B_PWM/configs/mcuconf.h | 12 ++++ .../boards/SN_SN32F240C/configs/mcuconf.h | 69 +++++++++++++++++++ .../boards/SN_SN32F260/configs/mcuconf.h | 65 +++++++++++++++++ .../boards/SN_SN32F290/configs/mcuconf.h | 69 +++++++++++++++++++ 5 files changed, 284 insertions(+) create mode 100644 platforms/chibios/boards/SN_SN32F240B/configs/mcuconf.h create mode 100644 platforms/chibios/boards/SN_SN32F240C/configs/mcuconf.h create mode 100644 platforms/chibios/boards/SN_SN32F260/configs/mcuconf.h create mode 100644 platforms/chibios/boards/SN_SN32F290/configs/mcuconf.h diff --git a/platforms/chibios/boards/SN_SN32F240B/configs/mcuconf.h b/platforms/chibios/boards/SN_SN32F240B/configs/mcuconf.h new file mode 100644 index 000000000000..a1b529eb85a4 --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F240B/configs/mcuconf.h @@ -0,0 +1,69 @@ +/* + ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio + + 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 + +/* + * SN32F24xB drivers configuration. + * The following settings override the default settings present in + * the various device driver implementation headers. + * Note that the settings for each driver only have effect if the whole + * driver is enabled in halconf.h. + * + * IRQ priorities: + * 3...0 Lowest...Highest. + * + * DMA priorities: + * 0...3 Lowest...Highest. + */ + +#define SN32F24xB_MCUCONF +#define PLATFORM_MCUCONF +/* + * HAL driver system settings. + */ +/* + * CT driver system settings. + */ +// Defaults are correct +/* + * PWM driver system settings. + */ +// Defaults are correct +/* + * USB driver system settings. + */ +// Defaults are correct +/* + * SPI driver system settings. + */ +// Defaults are correct +/* + * I2C driver system settings. + */ +// Defaults are correct +/* + * UART driver system settings. + */ +// Defaults are correct +/* + * System Clock settings. + */ +// Defaults are correct + + +#endif /* MCUCONF_H */ diff --git a/platforms/chibios/boards/SN_SN32F240B_PWM/configs/mcuconf.h b/platforms/chibios/boards/SN_SN32F240B_PWM/configs/mcuconf.h index 3f5c9ab92b3b..e90e97b4b417 100644 --- a/platforms/chibios/boards/SN_SN32F240B_PWM/configs/mcuconf.h +++ b/platforms/chibios/boards/SN_SN32F240B_PWM/configs/mcuconf.h @@ -49,6 +49,18 @@ * USB driver system settings. */ // Defaults are correct +/* + * SPI driver system settings. + */ +// Defaults are correct +/* + * I2C driver system settings. + */ +// Defaults are correct +/* + * UART driver system settings. + */ +// Defaults are correct /* * System Clock settings. */ diff --git a/platforms/chibios/boards/SN_SN32F240C/configs/mcuconf.h b/platforms/chibios/boards/SN_SN32F240C/configs/mcuconf.h new file mode 100644 index 000000000000..b920041440c0 --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F240C/configs/mcuconf.h @@ -0,0 +1,69 @@ +/* + ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio + + 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 + +/* + * SN32F24xC drivers configuration. + * The following settings override the default settings present in + * the various device driver implementation headers. + * Note that the settings for each driver only have effect if the whole + * driver is enabled in halconf.h. + * + * IRQ priorities: + * 3...0 Lowest...Highest. + * + * DMA priorities: + * 0...3 Lowest...Highest. + */ + +#define SN32F24xC_MCUCONF +#define PLATFORM_MCUCONF +/* + * HAL driver system settings. + */ +/* + * CT driver system settings. + */ +// Defaults are correct +/* + * PWM driver system settings. + */ +// Defaults are correct +/* + * USB driver system settings. + */ +// Defaults are correct +/* + * SPI driver system settings. + */ +// Defaults are correct +/* + * I2C driver system settings. + */ +// Defaults are correct +/* + * UART driver system settings. + */ +// Defaults are correct +/* + * System Clock settings. + */ +// Defaults are correct + + +#endif /* MCUCONF_H */ diff --git a/platforms/chibios/boards/SN_SN32F260/configs/mcuconf.h b/platforms/chibios/boards/SN_SN32F260/configs/mcuconf.h new file mode 100644 index 000000000000..9bc4fe369110 --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F260/configs/mcuconf.h @@ -0,0 +1,65 @@ +/* + ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio + + 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 + +/* + * SN32F26x drivers configuration. + * The following settings override the default settings present in + * the various device driver implementation headers. + * Note that the settings for each driver only have effect if the whole + * driver is enabled in halconf.h. + * + * IRQ priorities: + * 3...0 Lowest...Highest. + * + * DMA priorities: + * 0...3 Lowest...Highest. + */ + +#define SN32F26x_MCUCONF +#define PLATFORM_MCUCONF +/* + * HAL driver system settings. + */ +/* + * CT driver system settings. + */ +// Defaults are correct +/* + * PWM driver system settings. + */ +// Defaults are correct +/* + * USB driver system settings. + */ +// Defaults are correct +/* + * SPI driver system settings. + */ +// Defaults are correct +/* + * I2C driver system settings. + */ +// Defaults are correct +/* + * System Clock settings. + */ +// Defaults are correct + + +#endif /* MCUCONF_H */ diff --git a/platforms/chibios/boards/SN_SN32F290/configs/mcuconf.h b/platforms/chibios/boards/SN_SN32F290/configs/mcuconf.h new file mode 100644 index 000000000000..d4ed6b31a2e2 --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F290/configs/mcuconf.h @@ -0,0 +1,69 @@ +/* + ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio + + 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 + +/* + * SN32F29x drivers configuration. + * The following settings override the default settings present in + * the various device driver implementation headers. + * Note that the settings for each driver only have effect if the whole + * driver is enabled in halconf.h. + * + * IRQ priorities: + * 3...0 Lowest...Highest. + * + * DMA priorities: + * 0...3 Lowest...Highest. + */ + +#define SN32F29x_MCUCONF +#define PLATFORM_MCUCONF +/* + * HAL driver system settings. + */ +/* + * CT driver system settings. + */ +// Defaults are correct +/* + * PWM driver system settings. + */ +// Defaults are correct +/* + * USB driver system settings. + */ +// Defaults are correct +/* + * SPI driver system settings. + */ +// Defaults are correct +/* + * I2C driver system settings. + */ +// Defaults are correct +/* + * UART driver system settings. + */ +// Defaults are correct +/* + * System Clock settings. + */ +// Defaults are correct + + +#endif /* MCUCONF_H */ From b6350746e2d07fd0842f7d423c683ded42135b15 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 18 Dec 2024 12:24:03 +0200 Subject: [PATCH 12/16] sn32: onekey: 240c: enable i2c --- keyboards/handwired/onekey/sn32f240c/config.h | 3 +-- keyboards/handwired/onekey/sn32f240c/info.json | 9 --------- keyboards/handwired/onekey/sn32f240c/mcuconf.h | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 keyboards/handwired/onekey/sn32f240c/info.json diff --git a/keyboards/handwired/onekey/sn32f240c/config.h b/keyboards/handwired/onekey/sn32f240c/config.h index 22af1955aa2c..7d1bc0065fb1 100644 --- a/keyboards/handwired/onekey/sn32f240c/config.h +++ b/keyboards/handwired/onekey/sn32f240c/config.h @@ -15,10 +15,9 @@ */ #pragma once -/* + #define I2C_DRIVER I2CD0 #define I2C1_SCL_PIN A6 #define I2C1_SDA_PIN A7 #define I2C1_OPMODE OPMODE_I2C #define I2C1_CLOCK_SPEED 400000 -*/ \ No newline at end of file diff --git a/keyboards/handwired/onekey/sn32f240c/info.json b/keyboards/handwired/onekey/sn32f240c/info.json deleted file mode 100644 index d0eaa0ce636f..000000000000 --- a/keyboards/handwired/onekey/sn32f240c/info.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "keyboard_name": "Onekey SN32F240C", - "processor": "SN32F248CF", - "bootloader": "sn32-dfu", - "matrix_pins": { - "cols": ["A8"], - "rows": ["D11"] - } -} diff --git a/keyboards/handwired/onekey/sn32f240c/mcuconf.h b/keyboards/handwired/onekey/sn32f240c/mcuconf.h index d8556da7b69c..5d79da961a36 100644 --- a/keyboards/handwired/onekey/sn32f240c/mcuconf.h +++ b/keyboards/handwired/onekey/sn32f240c/mcuconf.h @@ -15,5 +15,5 @@ */ #pragma once -//#define SN32_I2C_USE_I2C0 TRUE +#define SN32_I2C_USE_I2C0 TRUE #include_next From 4d49e2332d0537ca9232ec2b9649adabd6e13a06 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 18 Dec 2024 12:24:40 +0200 Subject: [PATCH 13/16] sn32: onekey: 290: enable i2c --- keyboards/handwired/onekey/sn32f290/config.h | 3 +-- keyboards/handwired/onekey/sn32f290/info.json | 9 --------- keyboards/handwired/onekey/sn32f290/mcuconf.h | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 keyboards/handwired/onekey/sn32f290/info.json diff --git a/keyboards/handwired/onekey/sn32f290/config.h b/keyboards/handwired/onekey/sn32f290/config.h index 22af1955aa2c..7d1bc0065fb1 100644 --- a/keyboards/handwired/onekey/sn32f290/config.h +++ b/keyboards/handwired/onekey/sn32f290/config.h @@ -15,10 +15,9 @@ */ #pragma once -/* + #define I2C_DRIVER I2CD0 #define I2C1_SCL_PIN A6 #define I2C1_SDA_PIN A7 #define I2C1_OPMODE OPMODE_I2C #define I2C1_CLOCK_SPEED 400000 -*/ \ No newline at end of file diff --git a/keyboards/handwired/onekey/sn32f290/info.json b/keyboards/handwired/onekey/sn32f290/info.json deleted file mode 100644 index b8fbe8b6bfea..000000000000 --- a/keyboards/handwired/onekey/sn32f290/info.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "keyboard_name": "Onekey SN32F290", - "processor": "SN32F299F", - "bootloader": "sn32-dfu", - "matrix_pins": { - "cols": ["A8"], - "rows": ["D11"] - } -} diff --git a/keyboards/handwired/onekey/sn32f290/mcuconf.h b/keyboards/handwired/onekey/sn32f290/mcuconf.h index d8556da7b69c..5d79da961a36 100644 --- a/keyboards/handwired/onekey/sn32f290/mcuconf.h +++ b/keyboards/handwired/onekey/sn32f290/mcuconf.h @@ -15,5 +15,5 @@ */ #pragma once -//#define SN32_I2C_USE_I2C0 TRUE +#define SN32_I2C_USE_I2C0 TRUE #include_next From 070906b9028795f7e2bcc5eae1fa2f19409f4a63 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 18 Dec 2024 12:37:44 +0200 Subject: [PATCH 14/16] sn32: onekey: splittest: add 240c --- .../handwired/splittest/sn32f240c/config.h | 10 +++ .../handwired/splittest/sn32f240c/halconf.h | 13 ++++ .../splittest/sn32f240c/keyboard.json | 15 +++++ .../handwired/splittest/sn32f240c/mcuconf.h | 18 +++++ .../splittest/sn32f240c/post_config.h | 26 ++++++++ .../handwired/splittest/sn32f240c/readme.md | 66 +++++++++++++++++++ 6 files changed, 148 insertions(+) create mode 100644 keyboards/handwired/splittest/sn32f240c/config.h create mode 100644 keyboards/handwired/splittest/sn32f240c/halconf.h create mode 100644 keyboards/handwired/splittest/sn32f240c/keyboard.json create mode 100644 keyboards/handwired/splittest/sn32f240c/mcuconf.h create mode 100644 keyboards/handwired/splittest/sn32f240c/post_config.h create mode 100644 keyboards/handwired/splittest/sn32f240c/readme.md diff --git a/keyboards/handwired/splittest/sn32f240c/config.h b/keyboards/handwired/splittest/sn32f240c/config.h new file mode 100644 index 000000000000..7a2ba5ab1496 --- /dev/null +++ b/keyboards/handwired/splittest/sn32f240c/config.h @@ -0,0 +1,10 @@ +// Copyright 2024 Dimitris Mantzouranis (@dexter93) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define SPLIT_HAND_PIN A7 + +#if !(defined(USE_SDI0) || defined(USE_SDI1) || defined(USE_SDI2)) + #define USE_SDI0 +#endif \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f240c/halconf.h b/keyboards/handwired/splittest/sn32f240c/halconf.h new file mode 100644 index 000000000000..ecbe196c6363 --- /dev/null +++ b/keyboards/handwired/splittest/sn32f240c/halconf.h @@ -0,0 +1,13 @@ +// Copyright 2024 Dimitris Mantzouranis (@dexter93) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +/* Needed for serial bitbang, half-duplex and full-duplex */ +#define HAL_USE_PAL TRUE +// Needed for serial bitbang +//#define PAL_USE_WAIT TRUE +//#define PAL_USE_CALLBACKS TRUE +#include_next +#undef HAL_USE_PWM +#define HAL_USE_PWM FALSE \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f240c/keyboard.json b/keyboards/handwired/splittest/sn32f240c/keyboard.json new file mode 100644 index 000000000000..8d32a8432cff --- /dev/null +++ b/keyboards/handwired/splittest/sn32f240c/keyboard.json @@ -0,0 +1,15 @@ +{ + "matrix_pins": { + "cols": ["B1"], + "rows": ["B10"] + }, + "diode_direction": "COL2ROW", + "processor": "SN32F248CF", + "bootloader": "sn32-dfu", + "features": { + "bootmagic": false, + "mousekey": false, + "extrakey": false, + "console": true + } +} \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f240c/mcuconf.h b/keyboards/handwired/splittest/sn32f240c/mcuconf.h new file mode 100644 index 000000000000..51ef4a47ffb4 --- /dev/null +++ b/keyboards/handwired/splittest/sn32f240c/mcuconf.h @@ -0,0 +1,18 @@ +// Copyright 2024 Dimitris Mantzouranis (@dexter93) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + +// These are needed if the communication is on the SD0 UART, either with standard or alternate pins +#undef SN32_SERIAL_USE_UART0 +#define SN32_SERIAL_USE_UART0 TRUE + +// These are needed if the communication is on the SD1 UART, either with standard or alternate pins +//#undef SN32_SERIAL_USE_UART1 +//#define SN32_SERIAL_USE_UART1 TRUE + +// These are needed if the communication is on the SD2 UART, either with standard or alternate pins +//#undef SN32_SERIAL_USE_UART2 +//#define SN32_SERIAL_USE_UART2 TRUE \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f240c/post_config.h b/keyboards/handwired/splittest/sn32f240c/post_config.h new file mode 100644 index 000000000000..29165cc42694 --- /dev/null +++ b/keyboards/handwired/splittest/sn32f240c/post_config.h @@ -0,0 +1,26 @@ +// Copyright 2024 Dimitris Mantzouranis (@dexter93) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#if defined(SPLIT_SERIAL_FULLDUPLEX) +# define SERIAL_USART_FULL_DUPLEX // Enable full duplex operation mode. +#endif +#if defined(SPLIT_SERIAL_HALFDUPLEX) || defined(SPLIT_SERIAL_FULLDUPLEX) +# if defined(USE_SDI0) +# define SOFT_SERIAL_PIN A10 +# define SERIAL_USART_RX_PIN A11 // USART RX pin +# define SERIAL_USART_DRIVER SD0 +# elif defined(USE_SDI1) +# define SOFT_SERIAL_PIN B9 +# define SERIAL_USART_RX_PIN B8 // USART RX pin +# elif defined(USE_SDI2) +# define SOFT_SERIAL_PIN A1 +# define SERIAL_USART_RX_PIN A0 // USART RX pin +# define SERIAL_USART_DRIVER SD2 // USART driver of TX and RX pin. default: SD1 +# else +# error "splittest serial keymap is missing a configuration" +# endif +#else // defined(SPLIT_BITBANG) +# define SOFT_SERIAL_PIN B8 +#endif \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f240c/readme.md b/keyboards/handwired/splittest/sn32f240c/readme.md new file mode 100644 index 000000000000..20125ddf35f8 --- /dev/null +++ b/keyboards/handwired/splittest/sn32f240c/readme.md @@ -0,0 +1,66 @@ +# sn32f240c splittest + +This is the splittest example for the sn32f240c MCU. +To trigger keypress, short together pins _B10_ and _B1_. + +## Keyboard Configuration + +The type of communication (bitbang, serial (half/full duplex)) is set by the keymap `config.h` file with variables with `SPLIT_` prefix. +So this example uses: + +- `config.h` to set which SDI to use for serial. Either define `USE_SDI0`, `USE_SDI1` or `USE_SDI2` before the `#ifdef` that configures the default case when none of these variable is defined. +- `post_config.h` for defining the communication pins between the halves once the keymap is configured. + +On your keyboard, you most likely will only use `config.h` because you'd have already chosen your communication scheme: serial type, SDI, pins. + +## Wiring + +### Switches + +- Add switches to both sn32f240c across B10 and B1 pins + +### Handedness + +Have a look at the [handedness documentation](https://docs.qmk.fm/#/feature_split_keyboard?id=setting-handedness) + +- Add pull-up resistor to left side between VCC and A7 +- Add pull-down resistors to right side between GND and A7 + +### Send power to the other half + +- Connect the following pins on both sides together: GND, VCC + +### Halves data connection + +Choose one of the connection type + +#### serial - bitbang + +- Connect the B8 pins on both sides together +- Note that bitbang functionality requires strict timings. Currently not supported. + +#### serial - usart half duplex + +Check the [documentation](https://docs.qmk.fm/#/serial_driver?id=usart-half-duplex) to determine the pull-up resistor. + +- To use the default usart (UART0), + - Connect the A10, A11 pins on both sides together and to add a pull-up resistor on one of these pins + - Define USE_SDI0 in config.h +- To use the second usart (UART1), + - Connect the B8, B9 pins on both sides together and to add a pull-up resistor on one of these pins + - Define USE_SDI1 in config.h +- To use the third usart (UART2), + - Connect the A0, A1 pins on both sides together and to add a pull-up resistor on one of these pins + - Define USE_SDI1 in config.h + +#### serial - usart full duplex + +- To use the default usart (UART0), + - Connect the pins on A10, A11 one to the other on each side + - Define USE_SDI0 in config.h +- To use the second usart (UART1), + - Connect the pins B8, B9 one to the other on each side + - Define USE_SDI1 in config.h +- To use the third usart2 (UART2) pins, + - Connect the pins A0, A1 one to the other on each side + - Define USE_SDI2 in config.h \ No newline at end of file From 62032e332b211effc21525f72525987a627dd97d Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 18 Dec 2024 12:38:07 +0200 Subject: [PATCH 15/16] sn32: onekey: splittest: add 290 --- .../handwired/splittest/sn32f290/config.h | 10 +++ .../handwired/splittest/sn32f290/halconf.h | 13 ++++ .../splittest/sn32f290/keyboard.json | 15 ++++ .../handwired/splittest/sn32f290/mcuconf.h | 22 ++++++ .../splittest/sn32f290/post_config.h | 30 ++++++++ .../handwired/splittest/sn32f290/readme.md | 72 +++++++++++++++++++ 6 files changed, 162 insertions(+) create mode 100644 keyboards/handwired/splittest/sn32f290/config.h create mode 100644 keyboards/handwired/splittest/sn32f290/halconf.h create mode 100644 keyboards/handwired/splittest/sn32f290/keyboard.json create mode 100644 keyboards/handwired/splittest/sn32f290/mcuconf.h create mode 100644 keyboards/handwired/splittest/sn32f290/post_config.h create mode 100644 keyboards/handwired/splittest/sn32f290/readme.md diff --git a/keyboards/handwired/splittest/sn32f290/config.h b/keyboards/handwired/splittest/sn32f290/config.h new file mode 100644 index 000000000000..3dbc8d915a83 --- /dev/null +++ b/keyboards/handwired/splittest/sn32f290/config.h @@ -0,0 +1,10 @@ +// Copyright 2024 Dimitris Mantzouranis (@dexter93) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#define SPLIT_HAND_PIN A7 + +#if !(defined(USE_SDI0) || defined(USE_SDI1) || defined(USE_SDI2) || defined(USE_SDI3)) + #define USE_SDI0 +#endif \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f290/halconf.h b/keyboards/handwired/splittest/sn32f290/halconf.h new file mode 100644 index 000000000000..ecbe196c6363 --- /dev/null +++ b/keyboards/handwired/splittest/sn32f290/halconf.h @@ -0,0 +1,13 @@ +// Copyright 2024 Dimitris Mantzouranis (@dexter93) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +/* Needed for serial bitbang, half-duplex and full-duplex */ +#define HAL_USE_PAL TRUE +// Needed for serial bitbang +//#define PAL_USE_WAIT TRUE +//#define PAL_USE_CALLBACKS TRUE +#include_next +#undef HAL_USE_PWM +#define HAL_USE_PWM FALSE \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f290/keyboard.json b/keyboards/handwired/splittest/sn32f290/keyboard.json new file mode 100644 index 000000000000..e08f57d6fdde --- /dev/null +++ b/keyboards/handwired/splittest/sn32f290/keyboard.json @@ -0,0 +1,15 @@ +{ + "matrix_pins": { + "cols": ["B1"], + "rows": ["B10"] + }, + "diode_direction": "COL2ROW", + "processor": "SN32F299F", + "bootloader": "sn32-dfu", + "features": { + "bootmagic": false, + "mousekey": false, + "extrakey": false, + "console": true + } +} \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f290/mcuconf.h b/keyboards/handwired/splittest/sn32f290/mcuconf.h new file mode 100644 index 000000000000..c88ffa2048dc --- /dev/null +++ b/keyboards/handwired/splittest/sn32f290/mcuconf.h @@ -0,0 +1,22 @@ +// Copyright 2024 Dimitris Mantzouranis (@dexter93) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include_next + +// These are needed if the communication is on the SD0 UART, either with standard or alternate pins +#undef SN32_SERIAL_USE_UART0 +#define SN32_SERIAL_USE_UART0 TRUE + +// These are needed if the communication is on the SD1 UART, either with standard or alternate pins +//#undef SN32_SERIAL_USE_UART1 +//#define SN32_SERIAL_USE_UART1 TRUE + +// These are needed if the communication is on the SD2 UART, either with standard or alternate pins +//#undef SN32_SERIAL_USE_UART2 +//#define SN32_SERIAL_USE_UART2 TRUE + +// These are needed if the communication is on the SD3 UART, either with standard or alternate pins +//#undef SN32_SERIAL_USE_UART3 +//#define SN32_SERIAL_USE_UART3 TRUE \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f290/post_config.h b/keyboards/handwired/splittest/sn32f290/post_config.h new file mode 100644 index 000000000000..bc5d0beb8aca --- /dev/null +++ b/keyboards/handwired/splittest/sn32f290/post_config.h @@ -0,0 +1,30 @@ +// Copyright 2024 Dimitris Mantzouranis (@dexter93) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#if defined(SPLIT_SERIAL_FULLDUPLEX) +# define SERIAL_USART_FULL_DUPLEX // Enable full duplex operation mode. +#endif +#if defined(SPLIT_SERIAL_HALFDUPLEX) || defined(SPLIT_SERIAL_FULLDUPLEX) +# if defined(USE_SDI0) +# define SOFT_SERIAL_PIN A10 +# define SERIAL_USART_RX_PIN A11 // USART RX pin +# define SERIAL_USART_DRIVER SD0 +# elif defined(USE_SDI1) +# define SOFT_SERIAL_PIN B9 +# define SERIAL_USART_RX_PIN B8 // USART RX pin +# elif defined(USE_SDI2) +# define SOFT_SERIAL_PIN A1 +# define SERIAL_USART_RX_PIN A2 // USART RX pin +# define SERIAL_USART_DRIVER SD2 +# elif defined(USE_SDI3) +# define SOFT_SERIAL_PIN D12 +# define SERIAL_USART_RX_PIN D13 // USART RX pin +# define SERIAL_USART_DRIVER SD3 // USART driver of TX and RX pin. default: SD1 +# else +# error "splittest serial keymap is missing a configuration" +# endif +#else // defined(SPLIT_BITBANG) +# define SOFT_SERIAL_PIN B8 +#endif \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f290/readme.md b/keyboards/handwired/splittest/sn32f290/readme.md new file mode 100644 index 000000000000..cfabbd7c2496 --- /dev/null +++ b/keyboards/handwired/splittest/sn32f290/readme.md @@ -0,0 +1,72 @@ +# sn32f290 splittest + +This is the splittest example for the sn32f290 MCU. +To trigger keypress, short together pins _B10_ and _B1_. + +## Keyboard Configuration + +The type of communication (bitbang, serial (half/full duplex)) is set by the keymap `config.h` file with variables with `SPLIT_` prefix. +So this example uses: + +- `config.h` to set which SDI to use for serial. Either define `USE_SDI0`, `USE_SDI1` , `USE_SDI2 `or `USE_SDI3` before the `#ifdef` that configures the default case when none of these variable is defined. +- `post_config.h` for defining the communication pins between the halves once the keymap is configured. + +On your keyboard, you most likely will only use `config.h` because you'd have already chosen your communication scheme: serial type, SDI, pins. + +## Wiring + +### Switches + +- Add switches to both sn32f290 across B10 and B1 pins + +### Handedness + +Have a look at the [handedness documentation](https://docs.qmk.fm/#/feature_split_keyboard?id=setting-handedness) + +- Add pull-up resistor to left side between VCC and A7 +- Add pull-down resistors to right side between GND and A7 + +### Send power to the other half + +- Connect the following pins on both sides together: GND, VCC + +### Halves data connection + +Choose one of the connection type + +#### serial - bitbang + +- Connect the B8 pins on both sides together +- Note that bitbang functionality requires strict timings. Currently not supported. + +#### serial - usart half duplex + +Check the [documentation](https://docs.qmk.fm/#/serial_driver?id=usart-half-duplex) to determine the pull-up resistor. + +- To use the default usart (UART0), + - Connect the A10, A11 pins on both sides together and to add a pull-up resistor on one of these pins + - Define USE_SDI0 in config.h +- To use the second usart (UART1), + - Connect the B8, B9 pins on both sides together and to add a pull-up resistor on one of these pins + - Define USE_SDI1 in config.h +- To use the third usart (UART2), + - Connect the A1, A2 pins on both sides together and to add a pull-up resistor on one of these pins + - Define USE_SDI2 in config.h +- To use the fourth usart (UART3), + - Connect the D12, D13 pins on both sides together and to add a pull-up resistor on one of these pins + - Define USE_SDI3 in config.h + +#### serial - usart full duplex + +- To use the default usart (UART0), + - Connect the pins on A10, A11 one to the other on each side + - Define USE_SDI0 in config.h +- To use the second usart (UART1), + - Connect the pins B8, B9 one to the other on each side + - Define USE_SDI1 in config.h +- To use the third usart2 (UART2) pins, + - Connect the pins A1, A2 one to the other on each side + - Define USE_SDI2 in config.h +- To use the fourth usart3 (UART3) pins, + - Connect the pins D12, D13 one to the other on each side + - Define USE_SDI3 in config.h \ No newline at end of file From 4a996c71c701ca5dd240869a45b91b15306a3315 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 18 Dec 2024 13:08:48 +0200 Subject: [PATCH 16/16] sn32: onekey: splittest: cleanup halconf --- keyboards/handwired/splittest/sn32f240b/halconf.h | 4 +--- keyboards/handwired/splittest/sn32f240c/halconf.h | 4 +--- keyboards/handwired/splittest/sn32f290/halconf.h | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/keyboards/handwired/splittest/sn32f240b/halconf.h b/keyboards/handwired/splittest/sn32f240b/halconf.h index ecbe196c6363..393a3bf978d6 100644 --- a/keyboards/handwired/splittest/sn32f240b/halconf.h +++ b/keyboards/handwired/splittest/sn32f240b/halconf.h @@ -8,6 +8,4 @@ // Needed for serial bitbang //#define PAL_USE_WAIT TRUE //#define PAL_USE_CALLBACKS TRUE -#include_next -#undef HAL_USE_PWM -#define HAL_USE_PWM FALSE \ No newline at end of file +#include_next \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f240c/halconf.h b/keyboards/handwired/splittest/sn32f240c/halconf.h index ecbe196c6363..393a3bf978d6 100644 --- a/keyboards/handwired/splittest/sn32f240c/halconf.h +++ b/keyboards/handwired/splittest/sn32f240c/halconf.h @@ -8,6 +8,4 @@ // Needed for serial bitbang //#define PAL_USE_WAIT TRUE //#define PAL_USE_CALLBACKS TRUE -#include_next -#undef HAL_USE_PWM -#define HAL_USE_PWM FALSE \ No newline at end of file +#include_next \ No newline at end of file diff --git a/keyboards/handwired/splittest/sn32f290/halconf.h b/keyboards/handwired/splittest/sn32f290/halconf.h index ecbe196c6363..393a3bf978d6 100644 --- a/keyboards/handwired/splittest/sn32f290/halconf.h +++ b/keyboards/handwired/splittest/sn32f290/halconf.h @@ -8,6 +8,4 @@ // Needed for serial bitbang //#define PAL_USE_WAIT TRUE //#define PAL_USE_CALLBACKS TRUE -#include_next -#undef HAL_USE_PWM -#define HAL_USE_PWM FALSE \ No newline at end of file +#include_next \ No newline at end of file