Skip to content

Commit 13a3852

Browse files
committed
Sonix SN32 platform support
Squashed commit of the following: commit c2a505582c7f2acb70d402a52bd28dc66d1812e4 Merge: 74b1b54 0c6e12c Author: dexter93 <[email protected]> Date: Thu Oct 27 21:21:55 2022 +0300 Merge pull request qmk#12 from dexter93/revert-11-sn32_up_wl Revert "Wear Leveling driver for SN32 platform" commit 0c6e12c Author: dexter93 <[email protected]> Date: Thu Oct 27 21:21:35 2022 +0300 Revert "Wear Leveling driver for SN32 platform" commit 74b1b54 Merge: 95b9528 3f4d1cb Author: dexter93 <[email protected]> Date: Thu Oct 27 19:35:46 2022 +0300 Merge pull request qmk#11 from Jpe230/sn32_up_wl Wear Leveling driver for SN32 platform commit 3f4d1cb Author: [email protected] <[email protected]> Date: Wed Oct 12 15:42:04 2022 -0500 Change page count commit 77f358d Author: [email protected] <[email protected]> Date: Wed Oct 12 15:32:43 2022 -0500 Rename SN32 WL driver, guard the last page commit 40a8d85 Author: [email protected] <[email protected]> Date: Wed Oct 12 15:14:22 2022 -0500 Fix typo on store_erase commit 95b9528 Author: Dimitris Mantzouranis <[email protected]> Date: Wed Oct 12 23:11:54 2022 +0300 260: cleanup config.h commit 2dc6b43 Author: [email protected] <[email protected]> Date: Wed Oct 12 15:05:41 2022 -0500 Wear-Leveling driver for SN32 platform commit b21897a Author: Dimitris Mantzouranis <[email protected]> Date: Wed Oct 12 22:50:33 2022 +0300 more config cleanup commit 4660b56 Author: Dimitris Mantzouranis <[email protected]> Date: Wed Oct 12 22:37:36 2022 +0300 move usb specifics out of chibios configs commit d6c6057 Author: Dimitris Mantzouranis <[email protected]> Date: Wed Oct 12 22:02:43 2022 +0300 apparently you can just cheese the preprocessor nice commit 7c84758 Author: Dimitris Mantzouranis <[email protected]> Date: Wed Oct 12 21:58:44 2022 +0300 Revert "common chconf.h: allow custom idle hooks" This reverts commit 92d5f99. commit 92d5f99 Author: Dimitris Mantzouranis <[email protected]> Date: Wed Oct 12 21:17:08 2022 +0300 common chconf.h: allow custom idle hooks commit a39707f Author: Dimitris Mantzouranis <[email protected]> Date: Wed Oct 12 21:06:45 2022 +0300 fall back to periodic tic timers aren't as good as we'd like. The VT in charge of them causes mayhem on double-buffered timers like CT16, resulting in random timekeeping commit 2e95cef Author: Dimitris Mantzouranis <[email protected]> Date: Wed Oct 12 21:02:01 2022 +0300 260: add board specific chconf commit 78ee352 Author: Dimitris Mantzouranis <[email protected]> Date: Wed Oct 12 20:59:10 2022 +0300 simplify configs based on common ones commit 33a4e82 Author: Dimitris Mantzouranis <[email protected]> Date: Wed Oct 12 20:53:20 2022 +0300 remove old eeprom code commit 90d9af2 Author: [email protected] <[email protected]> Date: Sat Oct 8 17:15:16 2022 -0500 Fix jsonschema, fix missing mcu_reset commit 14e3541 Author: [email protected] <[email protected]> Date: Sat Oct 8 17:10:26 2022 -0500 Add OneKey commit 420b913 Author: [email protected] <[email protected]> Date: Sat Oct 8 17:04:49 2022 -0500 Update BL commit 4f4408a Author: [email protected] <[email protected]> Date: Sat Oct 8 17:03:32 2022 -0500 Squashed commit of the following: commit 0533d61 Author: Nick Brassel <[email protected]> Date: Thu Jul 7 08:56:39 2022 +1000 Update keyboard.jsonschema Oops. commit 95d6beb Merge: ea8b4d8 744af00 Author: Nick Brassel <[email protected]> Date: Thu Jul 7 08:55:27 2022 +1000 Merge branch 'develop' into sonix commit ea8b4d8 Author: Dimitris Mantzouranis <[email protected]> Date: Sun Feb 13 15:23:10 2022 +0200 update configs for chibios 2.11 commit 45fd6d3 Author: Dimitris Mantzouranis <[email protected]> Date: Thu Mar 3 18:31:14 2022 +0200 use wait function for bootloader_jump commit 3a3b621 Author: Dimitris Mantzouranis <[email protected]> Date: Thu Mar 3 17:41:48 2022 +0200 add sonix sn32 in docs commit 4fbcb68 Author: Dimitris Mantzouranis <[email protected]> Date: Thu Mar 3 14:57:18 2022 +0200 sonix sn32f2xx platform support
1 parent 1914570 commit 13a3852

File tree

22 files changed

+622
-2
lines changed

22 files changed

+622
-2
lines changed

builddefs/mcu_selection.mk

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,102 @@ ifneq ($(findstring GD32VF103, $(MCU)),)
815815
USE_FPU ?= no
816816
endif
817817

818+
ifneq ($(findstring SN32F248F, $(MCU)),)
819+
# Cortex version
820+
MCU = cortex-m0
821+
822+
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
823+
ARMV = 6
824+
825+
## chip/board settings
826+
# - the next two should match the directories in
827+
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
828+
MCU_FAMILY = SN32
829+
MCU_SERIES = SN32F240
830+
831+
# Linker script to use
832+
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
833+
# or <keyboard_dir>/ld/
834+
MCU_LDSCRIPT ?= SN32F240
835+
836+
# Startup code to use
837+
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
838+
MCU_STARTUP ?= sn32f24x
839+
840+
# Board: it should exist either in <chibios>/os/hal/boards/,
841+
# <keyboard_dir>/boards/, or drivers/boards/
842+
BOARD ?= SN_SN32F240
843+
844+
USE_FPU ?= no
845+
846+
# Bootloader address for SN32 DFU
847+
SN32_BOOTLOADER_ADDRESS = 0x1FFF0301
848+
endif
849+
850+
ifneq ($(findstring SN32F248BF, $(MCU)),)
851+
# Cortex version
852+
MCU = cortex-m0
853+
854+
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
855+
ARMV = 6
856+
857+
## chip/board settings
858+
# - the next two should match the directories in
859+
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
860+
MCU_FAMILY = SN32
861+
MCU_SERIES = SN32F240B
862+
863+
# Linker script to use
864+
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
865+
# or <keyboard_dir>/ld/
866+
MCU_LDSCRIPT ?= SN32F240B
867+
868+
# Startup code to use
869+
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
870+
MCU_STARTUP ?= sn32f24xb
871+
872+
# Board: it should exist either in <chibios>/os/hal/boards/,
873+
# <keyboard_dir>/boards/, or drivers/boards/
874+
BOARD ?= SN_SN32F240B
875+
876+
USE_FPU ?= no
877+
878+
# Bootloader address for SN32 DFU
879+
SN32_BOOTLOADER_ADDRESS = 0x1FFF0301
880+
endif
881+
882+
ifneq ($(findstring SN32F268F, $(MCU)),)
883+
# Cortex version
884+
MCU = cortex-m0
885+
886+
# ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7
887+
ARMV = 6
888+
889+
## chip/board settings
890+
# - the next two should match the directories in
891+
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
892+
MCU_FAMILY = SN32
893+
MCU_SERIES = SN32F260
894+
895+
# Linker script to use
896+
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
897+
# or <keyboard_dir>/ld/
898+
MCU_LDSCRIPT ?= SN32F260
899+
900+
# Startup code to use
901+
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
902+
MCU_STARTUP ?= sn32f26x
903+
904+
# Board: it should exist either in <chibios>/os/hal/boards/,
905+
# <keyboard_dir>/boards/, or drivers/boards/
906+
BOARD ?= SN_SN32F260
907+
908+
USE_FPU ?= no
909+
910+
# Bootloader address for SN32 DFU
911+
SN32_BOOTLOADER_ADDRESS = 0x1FFF0009
912+
endif
913+
818914
ifneq (,$(filter $(MCU),at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647 at90usb1286 at90usb1287))
819915
PROTOCOL = LUFA
820916

data/schemas/keyboard.jsonschema

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
"MK64FX512",
6060
"MK66FX1M0",
6161
"RP2040",
62+
"SN32F248F",
63+
"SN32F248BF",
64+
"SN32F268F",
6265
"STM32F042",
6366
"STM32F072",
6467
"STM32F103",
@@ -155,7 +158,8 @@
155158
"tinyuf2",
156159
"unknown",
157160
"usbasploader",
158-
"wb32-dfu"
161+
"wb32-dfu",
162+
"sn32-dfu"
159163
]
160164
},
161165
"bootloader_instructions": {

docs/compatible_microcontrollers.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ You can also use any ARM chip with USB that [ChibiOS](https://www.chibios.org) s
7373

7474
For a detailed overview about the RP2040 support by QMK see the [dedicated RP2040 page](platformdev_rp2040.md).
7575

76+
### Sonix (SN32)
77+
78+
* [SN32F24x](https://www.sonix.com.tw/article-en-998-21396)
79+
* [SN32F24xB](https://www.sonix.com.tw/article-en-4336-30356)
80+
* [SN32F26x](https://www.sonix.com.tw/article-en-998-24753)
81+
7682
## Atmel ATSAM
7783

7884
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). However, it is not recommended to design a board with this microcontroller as the support is quite specialized to Massdrop hardware.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Copyright 2022 Jpe230
2+
// SPDX-License-Identifier: GPL-2.0-or-later
3+
4+
#pragma once
5+
6+
#include "config_common.h"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"keyboard_name": "Onekey SN32",
3+
"processor": "SN32F248BF",
4+
"bootloader": "sn32-dfu",
5+
"matrix_pins": {
6+
"cols": ["A8"],
7+
"rows": ["D11"]
8+
}
9+
}

keyboards/handwired/onekey/sn32/rules.mk

Whitespace-only changes.

lib/python/qmk/constants.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
MAX_KEYBOARD_SUBFOLDERS = 5
1515

1616
# Supported processor types
17-
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', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95'
17+
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', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95', 'SN32F248F', 'SN32F248BF', 'SN32F268F'
1818
LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None
1919
VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85'
2020

@@ -45,6 +45,9 @@
4545
"GD32VF103": "gd32v-dfu",
4646
"WB32F3G71": "wb32-dfu",
4747
"WB32FQ95": "wb32-dfu",
48+
"SN32F248F": "sn32-dfu",
49+
"SN32F248BF": "sn32-dfu",
50+
"SN32F268F": "sn32-dfu",
4851
"atmega16u2": "atmel-dfu",
4952
"atmega32u2": "atmel-dfu",
5053
"atmega16u4": "atmel-dfu",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# List of all the board related files.
2+
BOARDSRC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240/board.c
3+
4+
# Required include directories
5+
BOARDINC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240
6+
7+
# Optimize for speed
8+
OPT = 2
9+
10+
# Shared variables
11+
ALLCSRC += $(BOARDSRC)
12+
ALLINC += $(BOARDINC)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Copyright 2020 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+
/*
18+
* This file was auto-generated by:
19+
* `qmk chibios-confmigrate -i platforms/chibios/boards/SN_SN32F240/configs/chconf.h -r platforms/chibios/boards/common/configs/chconf.h`
20+
*/
21+
22+
#pragma once
23+
24+
#define CH_CFG_ST_TIMEDELTA 0
25+
26+
#include_next <chconf.h>
27+
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
#ifndef MCUCONF_H
18+
#define MCUCONF_H
19+
20+
/*
21+
* SN32F24x drivers configuration.
22+
* The following settings override the default settings present in
23+
* the various device driver implementation headers.
24+
* Note that the settings for each driver only have effect if the whole
25+
* driver is enabled in halconf.h.
26+
*
27+
* IRQ priorities:
28+
* 3...0 Lowest...Highest.
29+
*
30+
* DMA priorities:
31+
* 0...3 Lowest...Highest.
32+
*/
33+
34+
#define SN32F24x_MCUCONF
35+
#define PLATFORM_MCUCONF
36+
/*
37+
* HAL driver system settings.
38+
*/
39+
/*
40+
* CT driver system settings.
41+
*/
42+
#define SN32_HAS_CT16B0 TRUE
43+
#define SN32_HAS_CT16B1 TRUE
44+
45+
/*
46+
* SN driver system settings.
47+
*/
48+
#define SN32_HAS_GPIOA TRUE
49+
#define SN32_HAS_GPIOB TRUE
50+
#define SN32_HAS_GPIOC TRUE
51+
#define SN32_HAS_GPIOD TRUE
52+
53+
/*
54+
* USB driver system settings.
55+
*/
56+
#define CRT1_AREAS_NUMBER 1
57+
#define PLATFORM_USB_USE_USB1 TRUE
58+
59+
/*
60+
* Timer driver system settings.
61+
*/
62+
#define SYS_CLOCK_SETUP 1
63+
#define SYS0_CLKCFG_VAL 0
64+
#define AHB_PRESCALAR 0x2
65+
#define CLKOUT_SEL_VAL 0x0
66+
#define CLKOUT_PRESCALAR 0x0
67+
68+
#endif /* MCUCONF_H */
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# List of all the board related files.
2+
BOARDSRC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240B/board.c
3+
4+
# Required include directories
5+
BOARDINC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240B
6+
7+
# Optimize for speed
8+
OPT = 2
9+
# Enter lower-power sleep mode when on the ChibiOS idle thread
10+
OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE
11+
# Shave some extra bytes
12+
OPT_DEFS += -DCRT1_AREAS_NUMBER=1
13+
14+
# Shared variables
15+
ALLCSRC += $(BOARDSRC)
16+
ALLINC += $(BOARDINC)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* Copyright 2020 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+
/*
18+
* This file was auto-generated by:
19+
* `qmk chibios-confmigrate -i platforms/chibios/boards/SN_SN32F240B/configs/chconf.h -r platforms/chibios/boards/common/configs/chconf.h`
20+
*/
21+
22+
#pragma once
23+
24+
#define CH_CFG_ST_FREQUENCY 10000
25+
26+
#define CH_CFG_ST_TIMEDELTA 0
27+
28+
#include_next <chconf.h>
29+
30+
#undef CH_CFG_IDLE_ENTER_HOOK
31+
#define CH_CFG_IDLE_ENTER_HOOK() { \
32+
SN_PMU->CTRL = 4; \
33+
}
34+
35+
#undef CH_CFG_IDLE_LEAVE_HOOK
36+
#define CH_CFG_IDLE_LEAVE_HOOK() { \
37+
SN_PMU->CTRL = 0; \
38+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Copyright 2020 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+
/*
18+
* This file was auto-generated by:
19+
* `qmk chibios-confmigrate -i platforms/chibios/boards/SN_SN32F240B/configs/halconf.h -r platforms/chibios/boards/common/configs/halconf.h`
20+
*/
21+
22+
#pragma once
23+
24+
#define HAL_USE_PWM TRUE
25+
26+
#include_next <halconf.h>
27+

0 commit comments

Comments
 (0)