From 2bfa2a5534922ab8f7e1a66740ea269659a5bc7b Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 11 Sep 2024 16:15:45 +0300 Subject: [PATCH 1/4] sn32: platforms: seperate PWM board configs for shared matrix boards --- .../boards/SN_SN32F240B_PWM/board/board.mk | 16 +++++ .../boards/SN_SN32F240B_PWM/configs/chconf.h | 38 ++++++++++++ .../boards/SN_SN32F240B_PWM/configs/config.h | 20 +++++++ .../configs/halconf.h | 0 .../configs/mcuconf.h | 0 .../boards/SN_SN32F260/configs/mcuconf.h | 60 ------------------- 6 files changed, 74 insertions(+), 60 deletions(-) create mode 100644 platforms/chibios/boards/SN_SN32F240B_PWM/board/board.mk create mode 100644 platforms/chibios/boards/SN_SN32F240B_PWM/configs/chconf.h create mode 100644 platforms/chibios/boards/SN_SN32F240B_PWM/configs/config.h rename platforms/chibios/boards/{SN_SN32F240B => SN_SN32F240B_PWM}/configs/halconf.h (100%) rename platforms/chibios/boards/{SN_SN32F240B => SN_SN32F240B_PWM}/configs/mcuconf.h (100%) delete mode 100644 platforms/chibios/boards/SN_SN32F260/configs/mcuconf.h diff --git a/platforms/chibios/boards/SN_SN32F240B_PWM/board/board.mk b/platforms/chibios/boards/SN_SN32F240B_PWM/board/board.mk new file mode 100644 index 000000000000..b3cf15dd678c --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F240B_PWM/board/board.mk @@ -0,0 +1,16 @@ +# List of all the board related files. +BOARDSRC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240B/board.c + +# Required include directories +BOARDINC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240B + +# 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_SN32F240B_PWM/configs/chconf.h b/platforms/chibios/boards/SN_SN32F240B_PWM/configs/chconf.h new file mode 100644 index 000000000000..d7ff07513251 --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F240B_PWM/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_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_SN32F240B_PWM/configs/config.h b/platforms/chibios/boards/SN_SN32F240B_PWM/configs/config.h new file mode 100644 index 000000000000..e11995725aae --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F240B_PWM/configs/config.h @@ -0,0 +1,20 @@ +/* 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 WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT +# define WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT 1 +# endif \ No newline at end of file diff --git a/platforms/chibios/boards/SN_SN32F240B/configs/halconf.h b/platforms/chibios/boards/SN_SN32F240B_PWM/configs/halconf.h similarity index 100% rename from platforms/chibios/boards/SN_SN32F240B/configs/halconf.h rename to platforms/chibios/boards/SN_SN32F240B_PWM/configs/halconf.h diff --git a/platforms/chibios/boards/SN_SN32F240B/configs/mcuconf.h b/platforms/chibios/boards/SN_SN32F240B_PWM/configs/mcuconf.h similarity index 100% rename from platforms/chibios/boards/SN_SN32F240B/configs/mcuconf.h rename to platforms/chibios/boards/SN_SN32F240B_PWM/configs/mcuconf.h diff --git a/platforms/chibios/boards/SN_SN32F260/configs/mcuconf.h b/platforms/chibios/boards/SN_SN32F260/configs/mcuconf.h deleted file mode 100644 index 3b214efed4ff..000000000000 --- a/platforms/chibios/boards/SN_SN32F260/configs/mcuconf.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - 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. - */ -#define SN32_PWM_USE_CT16B1 TRUE -#define SN32_PWM_NO_RESET TRUE -/* - * USB driver system settings. - */ -// Defaults are correct - -/* - * System Clock settings. - */ -// Defaults are correct - - -#endif /* MCUCONF_H */ From 9ad508ef664802182be7f5c730aad4dff365a076 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 11 Sep 2024 16:18:07 +0300 Subject: [PATCH 2/4] sn32: schemas: add sn32f240b_shared_matrix use this for common configuration with shared key/led matrix --- data/mappings/defaults.hjson | 5 +++++ data/schemas/keyboard.jsonschema | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/data/mappings/defaults.hjson b/data/mappings/defaults.hjson index 71902c92d68c..a2f640564428 100644 --- a/data/mappings/defaults.hjson +++ b/data/mappings/defaults.hjson @@ -84,6 +84,11 @@ "board": "STEMCELL", "bootloader": "tinyuf2", "processor": "STM32F411" + }, + "sn32f240b_shared_matrix": { + "board": "SN_SN32F240B_PWM", + "bootloader": "sn32-dfu", + "processor": "SN32F248BF" } } } diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index acbf06599df7..37fe13353330 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -45,7 +45,7 @@ }, "development_board": { "type": "string", - "enum": ["promicro", "elite_c", "elite_pi", "proton_c", "kb2040", "promicro_rp2040", "blok", "michi", "bit_c_pro", "stemcell", "bluepill", "blackpill_f401", "blackpill_f411", "bonsai_c4", "helios", "liatris", "imera"] + "enum": ["promicro", "elite_c", "elite_pi", "proton_c", "kb2040", "promicro_rp2040", "blok", "michi", "bit_c_pro", "stemcell", "bluepill", "blackpill_f401", "blackpill_f411", "bonsai_c4", "helios", "liatris", "imera", "sn32f240b_shared_matrix"] }, "pin_compatible": { "type": "string", From 2f1abb81c346562cd1317c4e9b889f9ec55b3488 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 11 Sep 2024 16:44:20 +0300 Subject: [PATCH 3/4] sn32: boards: pwm: disable SWD on init --- .../boards/SN_SN32F240B_PWM/board/board.mk | 3 +++ .../boards/SN_SN32F240B_PWM/board/extra.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 platforms/chibios/boards/SN_SN32F240B_PWM/board/extra.c diff --git a/platforms/chibios/boards/SN_SN32F240B_PWM/board/board.mk b/platforms/chibios/boards/SN_SN32F240B_PWM/board/board.mk index b3cf15dd678c..21fdccf4ba1e 100644 --- a/platforms/chibios/boards/SN_SN32F240B_PWM/board/board.mk +++ b/platforms/chibios/boards/SN_SN32F240B_PWM/board/board.mk @@ -1,6 +1,9 @@ # List of all the board related files. BOARDSRC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240B/board.c +# Extra files +BOARDSRC += $(BOARD_PATH)/board/extra.c + # Required include directories BOARDINC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240B diff --git a/platforms/chibios/boards/SN_SN32F240B_PWM/board/extra.c b/platforms/chibios/boards/SN_SN32F240B_PWM/board/extra.c new file mode 100644 index 000000000000..8fc9a63bfb7b --- /dev/null +++ b/platforms/chibios/boards/SN_SN32F240B_PWM/board/extra.c @@ -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 . + */ +void board_init(void) { + SN_SYS0->EXRSTCTRL_b.RESETDIS = 1; // Disable RESET + SN_SYS0->SWDCTRL_b.SWDDIS = 1; // Disable SWD +} \ No newline at end of file From 5c413c23d9805d5bb0dcf2e67b8a0f5e0339d9e2 Mon Sep 17 00:00:00 2001 From: Dimitris Mantzouranis Date: Wed, 11 Sep 2024 16:46:57 +0300 Subject: [PATCH 4/4] sn32: boards: config.h: prefer EARLY_INIT_PERFORM_BOOTLOADER_JUMP --- .../chibios/boards/SN_SN32F240/configs/config.h | 10 +++++++--- .../chibios/boards/SN_SN32F240B/configs/config.h | 10 +++++++--- .../boards/SN_SN32F240B_PWM/configs/config.h | 10 +++++++--- .../chibios/boards/SN_SN32F260/configs/config.h | 14 +++++++++----- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/platforms/chibios/boards/SN_SN32F240/configs/config.h b/platforms/chibios/boards/SN_SN32F240/configs/config.h index e11995725aae..efdfd59387d7 100644 --- a/platforms/chibios/boards/SN_SN32F240/configs/config.h +++ b/platforms/chibios/boards/SN_SN32F240/configs/config.h @@ -15,6 +15,10 @@ */ #pragma once -# ifndef WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT -# define WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT 1 -# endif \ No newline at end of file +#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 diff --git a/platforms/chibios/boards/SN_SN32F240B/configs/config.h b/platforms/chibios/boards/SN_SN32F240B/configs/config.h index e11995725aae..efdfd59387d7 100644 --- a/platforms/chibios/boards/SN_SN32F240B/configs/config.h +++ b/platforms/chibios/boards/SN_SN32F240B/configs/config.h @@ -15,6 +15,10 @@ */ #pragma once -# ifndef WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT -# define WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT 1 -# endif \ No newline at end of file +#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 diff --git a/platforms/chibios/boards/SN_SN32F240B_PWM/configs/config.h b/platforms/chibios/boards/SN_SN32F240B_PWM/configs/config.h index e11995725aae..efdfd59387d7 100644 --- a/platforms/chibios/boards/SN_SN32F240B_PWM/configs/config.h +++ b/platforms/chibios/boards/SN_SN32F240B_PWM/configs/config.h @@ -15,6 +15,10 @@ */ #pragma once -# ifndef WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT -# define WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT 1 -# endif \ No newline at end of file +#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 diff --git a/platforms/chibios/boards/SN_SN32F260/configs/config.h b/platforms/chibios/boards/SN_SN32F260/configs/config.h index 0649129f080e..9b78399f898c 100644 --- a/platforms/chibios/boards/SN_SN32F260/configs/config.h +++ b/platforms/chibios/boards/SN_SN32F260/configs/config.h @@ -17,9 +17,13 @@ #pragma once -#define RAW_IN_CAPACITY 1 -#define RAW_OUT_CAPACITY 1 +#define RAW_IN_CAPACITY 1 +#define RAW_OUT_CAPACITY 1 -# ifndef WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT -# define WEAR_LEVELING_EFL_OMIT_LAST_SECTOR_COUNT 1 -# endif \ No newline at end of file +#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