Skip to content

Commit

Permalink
Sonix SN32 platform support
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit c2a505582c7f2acb70d402a52bd28dc66d1812e4
Merge: 74b1b54 0c6e12c
Author: dexter93 <d3xter93@gmail.com>
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 <d3xter93@gmail.com>
Date:   Thu Oct 27 21:21:35 2022 +0300

    Revert "Wear Leveling driver for SN32 platform"

commit 74b1b54
Merge: 95b9528 3f4d1cb
Author: dexter93 <d3xter93@gmail.com>
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: pablin.123.ra@gmail.com <pablin.123.ra@gmail.com>
Date:   Wed Oct 12 15:42:04 2022 -0500

    Change page count

commit 77f358d
Author: pablin.123.ra@gmail.com <pablin.123.ra@gmail.com>
Date:   Wed Oct 12 15:32:43 2022 -0500

    Rename SN32 WL driver, guard the last page

commit 40a8d85
Author: pablin.123.ra@gmail.com <pablin.123.ra@gmail.com>
Date:   Wed Oct 12 15:14:22 2022 -0500

    Fix typo on store_erase

commit 95b9528
Author: Dimitris Mantzouranis <d3xter93@gmail.com>
Date:   Wed Oct 12 23:11:54 2022 +0300

    260: cleanup config.h

commit 2dc6b43
Author: pablin.123.ra@gmail.com <pablin.123.ra@gmail.com>
Date:   Wed Oct 12 15:05:41 2022 -0500

    Wear-Leveling driver for SN32 platform

commit b21897a
Author: Dimitris Mantzouranis <d3xter93@gmail.com>
Date:   Wed Oct 12 22:50:33 2022 +0300

    more config cleanup

commit 4660b56
Author: Dimitris Mantzouranis <d3xter93@gmail.com>
Date:   Wed Oct 12 22:37:36 2022 +0300

    move usb specifics out of chibios configs

commit d6c6057
Author: Dimitris Mantzouranis <d3xter93@gmail.com>
Date:   Wed Oct 12 22:02:43 2022 +0300

    apparently you can just cheese the preprocessor

    nice

commit 7c84758
Author: Dimitris Mantzouranis <d3xter93@gmail.com>
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 <d3xter93@gmail.com>
Date:   Wed Oct 12 21:17:08 2022 +0300

    common chconf.h: allow custom idle hooks

commit a39707f
Author: Dimitris Mantzouranis <d3xter93@gmail.com>
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 <d3xter93@gmail.com>
Date:   Wed Oct 12 21:02:01 2022 +0300

    260: add board specific chconf

commit 78ee352
Author: Dimitris Mantzouranis <d3xter93@gmail.com>
Date:   Wed Oct 12 20:59:10 2022 +0300

    simplify configs based on common ones

commit 33a4e82
Author: Dimitris Mantzouranis <d3xter93@gmail.com>
Date:   Wed Oct 12 20:53:20 2022 +0300

    remove old eeprom code

commit 90d9af2
Author: pablin.123.ra@gmail.com <pablin.123.ra@gmail.com>
Date:   Sat Oct 8 17:15:16 2022 -0500

    Fix jsonschema, fix missing mcu_reset

commit 14e3541
Author: pablin.123.ra@gmail.com <pablin.123.ra@gmail.com>
Date:   Sat Oct 8 17:10:26 2022 -0500

    Add OneKey

commit 420b913
Author: pablin.123.ra@gmail.com <pablin.123.ra@gmail.com>
Date:   Sat Oct 8 17:04:49 2022 -0500

    Update BL

commit 4f4408a
Author: pablin.123.ra@gmail.com <pablin.123.ra@gmail.com>
Date:   Sat Oct 8 17:03:32 2022 -0500

    Squashed commit of the following:

    commit 0533d61
    Author: Nick Brassel <nick@tzarc.org>
    Date:   Thu Jul 7 08:56:39 2022 +1000

        Update keyboard.jsonschema

        Oops.

    commit 95d6beb
    Merge: ea8b4d8 744af00
    Author: Nick Brassel <nick@tzarc.org>
    Date:   Thu Jul 7 08:55:27 2022 +1000

        Merge branch 'develop' into sonix

    commit ea8b4d8
    Author: Dimitris Mantzouranis <d3xter93@gmail.com>
    Date:   Sun Feb 13 15:23:10 2022 +0200

        update configs for chibios 2.11

    commit 45fd6d3
    Author: Dimitris Mantzouranis <d3xter93@gmail.com>
    Date:   Thu Mar 3 18:31:14 2022 +0200

        use wait function for bootloader_jump

    commit 3a3b621
    Author: Dimitris Mantzouranis <d3xter93@gmail.com>
    Date:   Thu Mar 3 17:41:48 2022 +0200

        add sonix sn32 in docs

    commit 4fbcb68
    Author: Dimitris Mantzouranis <d3xter93@gmail.com>
    Date:   Thu Mar 3 14:57:18 2022 +0200

        sonix sn32f2xx platform support
  • Loading branch information
dexter93 committed Oct 27, 2022
1 parent 1914570 commit 13a3852
Show file tree
Hide file tree
Showing 22 changed files with 622 additions and 2 deletions.
96 changes: 96 additions & 0 deletions builddefs/mcu_selection.mk
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,102 @@ ifneq ($(findstring GD32VF103, $(MCU)),)
USE_FPU ?= no
endif

ifneq ($(findstring SN32F248F, $(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
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
MCU_FAMILY = SN32
MCU_SERIES = SN32F240

# Linker script to use
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
# or <keyboard_dir>/ld/
MCU_LDSCRIPT ?= SN32F240

# Startup code to use
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
MCU_STARTUP ?= sn32f24x

# Board: it should exist either in <chibios>/os/hal/boards/,
# <keyboard_dir>/boards/, or drivers/boards/
BOARD ?= SN_SN32F240

USE_FPU ?= no

# Bootloader address for SN32 DFU
SN32_BOOTLOADER_ADDRESS = 0x1FFF0301
endif

ifneq ($(findstring SN32F248BF, $(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
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
MCU_FAMILY = SN32
MCU_SERIES = SN32F240B

# Linker script to use
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
# or <keyboard_dir>/ld/
MCU_LDSCRIPT ?= SN32F240B

# Startup code to use
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
MCU_STARTUP ?= sn32f24xb

# Board: it should exist either in <chibios>/os/hal/boards/,
# <keyboard_dir>/boards/, or drivers/boards/
BOARD ?= SN_SN32F240B

USE_FPU ?= no

# Bootloader address for SN32 DFU
SN32_BOOTLOADER_ADDRESS = 0x1FFF0301
endif

ifneq ($(findstring SN32F268F, $(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
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
MCU_FAMILY = SN32
MCU_SERIES = SN32F260

# Linker script to use
# - it should exist either in <chibios>/os/common/ports/ARMCMx/compilers/GCC/ld/
# or <keyboard_dir>/ld/
MCU_LDSCRIPT ?= SN32F260

# Startup code to use
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
MCU_STARTUP ?= sn32f26x

# Board: it should exist either in <chibios>/os/hal/boards/,
# <keyboard_dir>/boards/, or drivers/boards/
BOARD ?= SN_SN32F260

USE_FPU ?= no

# Bootloader address for SN32 DFU
SN32_BOOTLOADER_ADDRESS = 0x1FFF0009
endif

ifneq (,$(filter $(MCU),at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647 at90usb1286 at90usb1287))
PROTOCOL = LUFA

Expand Down
6 changes: 5 additions & 1 deletion data/schemas/keyboard.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
"MK64FX512",
"MK66FX1M0",
"RP2040",
"SN32F248F",
"SN32F248BF",
"SN32F268F",
"STM32F042",
"STM32F072",
"STM32F103",
Expand Down Expand Up @@ -155,7 +158,8 @@
"tinyuf2",
"unknown",
"usbasploader",
"wb32-dfu"
"wb32-dfu",
"sn32-dfu"
]
},
"bootloader_instructions": {
Expand Down
6 changes: 6 additions & 0 deletions docs/compatible_microcontrollers.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ You can also use any ARM chip with USB that [ChibiOS](https://www.chibios.org) s

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

### Sonix (SN32)

* [SN32F24x](https://www.sonix.com.tw/article-en-998-21396)
* [SN32F24xB](https://www.sonix.com.tw/article-en-4336-30356)
* [SN32F26x](https://www.sonix.com.tw/article-en-998-24753)

## Atmel ATSAM

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.
Expand Down
6 changes: 6 additions & 0 deletions keyboards/handwired/onekey/sn32/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright 2022 Jpe230
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include "config_common.h"
9 changes: 9 additions & 0 deletions keyboards/handwired/onekey/sn32/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"keyboard_name": "Onekey SN32",
"processor": "SN32F248BF",
"bootloader": "sn32-dfu",
"matrix_pins": {
"cols": ["A8"],
"rows": ["D11"]
}
}
Empty file.
5 changes: 4 additions & 1 deletion lib/python/qmk/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95'
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'
LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None
VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85'

Expand Down Expand Up @@ -45,6 +45,9 @@
"GD32VF103": "gd32v-dfu",
"WB32F3G71": "wb32-dfu",
"WB32FQ95": "wb32-dfu",
"SN32F248F": "sn32-dfu",
"SN32F248BF": "sn32-dfu",
"SN32F268F": "sn32-dfu",
"atmega16u2": "atmel-dfu",
"atmega32u2": "atmel-dfu",
"atmega16u4": "atmel-dfu",
Expand Down
12 changes: 12 additions & 0 deletions platforms/chibios/boards/SN_SN32F240/board/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# List of all the board related files.
BOARDSRC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240/board.c

# Required include directories
BOARDINC = $(CHIBIOS_CONTRIB)/os/hal/boards/SN_SN32F240

# Optimize for speed
OPT = 2

# Shared variables
ALLCSRC += $(BOARDSRC)
ALLINC += $(BOARDINC)
27 changes: 27 additions & 0 deletions platforms/chibios/boards/SN_SN32F240/configs/chconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* 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 <http://www.gnu.org/licenses/>.
*/

/*
* This file was auto-generated by:
* `qmk chibios-confmigrate -i platforms/chibios/boards/SN_SN32F240/configs/chconf.h -r platforms/chibios/boards/common/configs/chconf.h`
*/

#pragma once

#define CH_CFG_ST_TIMEDELTA 0

#include_next <chconf.h>

68 changes: 68 additions & 0 deletions platforms/chibios/boards/SN_SN32F240/configs/mcuconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
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

/*
* SN32F24x 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 SN32F24x_MCUCONF
#define PLATFORM_MCUCONF
/*
* HAL driver system settings.
*/
/*
* CT driver system settings.
*/
#define SN32_HAS_CT16B0 TRUE
#define SN32_HAS_CT16B1 TRUE

/*
* SN driver system settings.
*/
#define SN32_HAS_GPIOA TRUE
#define SN32_HAS_GPIOB TRUE
#define SN32_HAS_GPIOC TRUE
#define SN32_HAS_GPIOD TRUE

/*
* USB driver system settings.
*/
#define CRT1_AREAS_NUMBER 1
#define PLATFORM_USB_USE_USB1 TRUE

/*
* Timer driver system settings.
*/
#define SYS_CLOCK_SETUP 1
#define SYS0_CLKCFG_VAL 0
#define AHB_PRESCALAR 0x2
#define CLKOUT_SEL_VAL 0x0
#define CLKOUT_PRESCALAR 0x0

#endif /* MCUCONF_H */
16 changes: 16 additions & 0 deletions platforms/chibios/boards/SN_SN32F240B/board/board.mk
Original file line number Diff line number Diff line change
@@ -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)
38 changes: 38 additions & 0 deletions platforms/chibios/boards/SN_SN32F240B/configs/chconf.h
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

/*
* 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_FREQUENCY 10000

#define CH_CFG_ST_TIMEDELTA 0

#include_next <chconf.h>

#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; \
}
27 changes: 27 additions & 0 deletions platforms/chibios/boards/SN_SN32F240B/configs/halconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* 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 <http://www.gnu.org/licenses/>.
*/

/*
* This file was auto-generated by:
* `qmk chibios-confmigrate -i platforms/chibios/boards/SN_SN32F240B/configs/halconf.h -r platforms/chibios/boards/common/configs/halconf.h`
*/

#pragma once

#define HAL_USE_PWM TRUE

#include_next <halconf.h>

Loading

0 comments on commit 13a3852

Please sign in to comment.