Skip to content

Commit

Permalink
Merge pull request qmk#6 from zhaqian12/qmk-zq
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
zhaqian12 authored May 24, 2022
2 parents a4c9387 + 06dd60b commit 9d33290
Show file tree
Hide file tree
Showing 18 changed files with 227 additions and 38 deletions.
44 changes: 34 additions & 10 deletions builddefs/mcu_selection.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
MCU_ORIG := $(MCU)

ifneq ($(findstring CH582, $(MCU)),)
# RISC-V
MCU = risc-v

# RISC-V extensions and abi configuration
MCU_ARCH = rv32imac
MCU_ABI = ilp32
MCU_CMODEL = medlow

## chip/board settings
# - the next two should match the directories in
# <chibios>/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)
MCU_FAMILY = CH58x
MCU_SERIES = CH582

# Linker script to use
# - it should exist either in <chibios>/os/common/startup/RISCV-ECLIC/compilers/GCC/ld/
# or <keyboard_dir>/ld/
MCU_LDSCRIPT ?= CH582M

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

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

USE_FPU ?= no
endif

ifneq ($(findstring MKL26Z64, $(MCU)),)
# Cortex version
MCU = cortex-m0plus
Expand Down Expand Up @@ -196,15 +227,9 @@ ifneq ($(findstring STM32F103, $(MCU)),)
MCU_FAMILY = STM32
MCU_SERIES = STM32F1xx

ifeq ($(strip $(BOOTLOADER)), tinyuf2)
MCU_LDSCRIPT ?= STM32F103x8_uf2
FIRMWARE_FORMAT ?= uf2
BOARD ?= STM32_F103_STM32DUINO
else
MCU_LDSCRIPT ?= STM32F103x8
BOARD ?= GENERIC_STM32_F103
endif

MCU_LDSCRIPT ?= STM32F103x8
BOARD ?= GENERIC_STM32_F103

# Startup code to use
# - it should exist in <chibios>/os/common/startup/ARMCMx/compilers/GCC/mk/
MCU_STARTUP ?= stm32f1xx
Expand Down Expand Up @@ -700,7 +725,6 @@ ifneq ($(findstring GD32VF103, $(MCU)),)
ifeq ($(strip $(BOOTLOADER)), tinyuf2)
MCU_LDSCRIPT ?= GD32VF103xB_uf2
FIRMWARE_FORMAT ?= uf2
OPT_DEFS += -DGD32VF103UF2
else
MCU_LDSCRIPT ?= GD32VF103xB
endif
Expand Down
15 changes: 6 additions & 9 deletions keyboards/zhaqian/gh60/rules.mk
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# MCU name
MCU = STM32F103
MCU_LDSCRIPT = STM32F103xB_uf2
FIRMWARE_FORMAT = uf2
BOARD = STM32_F103_STM32DUINO

# Bootloader selection
BOOTLOADER = tinyuf2

ifeq ($(strip $(BOOTLOADER)), tinyuf2)
MCU_LDSCRIPT = STM32F103x8_uf2
FIRMWARE_FORMAT = uf2
BOARD = STM32_F103_STM32DUINO
endif
BOOTLOADER = custom

# Build Options
# comment out to disable the options.
Expand All @@ -21,7 +18,7 @@ COMMAND_ENABLE = no
SLEEP_LED_ENABLE = no
NKRO_ENABLE = yes
RGBLIGHT_ENABLE = no
LTO_ENABLE = yes

OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE


SRC += uf2_boot.c
30 changes: 30 additions & 0 deletions keyboards/zhaqian/gh60/uf2_boot.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright 2022 ZhaQian
*
* 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/>.
*/

#include "bootloader.h"

#include <ch.h>

#define MAGIC_BOOT 0x544F4F42UL
#define MAGIC_REG *(volatile uint32_t*)0x20004000

void bootloader_jump(void) {
MAGIC_REG = MAGIC_BOOT;
NVIC_SystemReset();
}

void enter_bootloader_mode_if_requested(void) {}

24 changes: 21 additions & 3 deletions keyboards/zhaqian/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Readme Version
* [Enlish version](./readme.md)
* [Chinese version](./readme_cn.md)

# Table of Contents
- [Readme Version](#readme-version)
- [Table of Contents](#table-of-contents)
- [Keyboards Released by ZhaQian](#keyboards-released-by-zhaqian)
- [TODO LIST](#todo-list)
- [ZhaQian library](#zhaqian-library)
- [Alt Tab Marco](#alt-tab-marco)
- [Encoder Trigger](#encoder-trigger)
- [Joystick Trigger](#joystick-trigger)
- [Radial Controller](#radial-controller)
- [RGB Matrix Control](#rgb-matrix-control)
- [Underglow RGB Matrix](#underglow-rgb-matrix)
- [UF2 Bootloader](#uf2-bootloader)

# Keyboards Released by ZhaQian
| NAME | VENDOR_ID | PRODUCT_ID | PCB | MCU | FEATURES |
|:-------------:| :-------: | :--------: | :------: |:----------------: | :------------------------------------------: |
Expand Down Expand Up @@ -28,6 +43,12 @@
| zq50 | 0x00AA | 0xAA16 | Hotswap | ST stm32f103/f103 | RGB, UGRGB, ENCODER |
| Mpad12 | 0x00AA | 0xAAAA | Hotswap | Atmel atmega32u4 | RGB, UGRGB, JOYSTICK, ENCODER, OLED |
| split69 | 0x00AA | 0xAAAB | Solder | Atmel atmega32u4 | SPLIT, UGRGB, OLED, ENCODER |
| GH60 | 0xFEED | 0x6060 | Hotswap | ST stm32f103/f103 | RGB |
# TODO LIST
- BLE
- [ ] CH58X protocol of qmk
- [x] new kb firmware(use cherry usb)
- Rgb matrix control software (usb hid)

# ZhaQian library
This is a simple library that integrates some common repetitive functions.
Expand Down Expand Up @@ -163,7 +184,4 @@ You can also alternate these defines to control these feature:
|STM32F411xE|
|GD32VF103xB|

# TODO LIST

- Bluetooth (esp32s3,ch58x or nrf)
- Rgb matrix control software (usb hid)
16 changes: 15 additions & 1 deletion keyboards/zhaqian/readme_cn.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Readme Version
* [Enlish version](./readme.md)
* [Chinese version](./readme_cn.md)

# Table of Contents
- [Readme Version](#readme-version)
- [Table of Contents](#table-of-contents)
- [Keyboards Released by ZhaQian](#keyboards-released-by-zhaqian)
- [ZhaQian library](#zhaqian-library)
- [Alt Tab Marco](#alt-tab-marco)
- [Encoder Trigger](#encoder-trigger)
- [Joystick Trigger](#joystick-trigger)
- [Radial Controller](#radial-controller)
- [RGB Matrix Control](#rgb-matrix-control)
- [Underglow RGB Matrix](#underglow-rgb-matrix)
- [UF2 Bootloader](#uf2-bootloader)
- [TODO LIST](#todo-list)
# Keyboards Released by ZhaQian
| NAME | VENDOR_ID | PRODUCT_ID | PCB | MCU | FEATURES |
|:-------------:| :-------: | :--------: | :------: |:----------------: | :------------------------------------------: |
Expand Down Expand Up @@ -28,7 +42,7 @@
| zq50 | 0x00AA | 0xAA16 | Hotswap | ST stm32f103/f103 | RGB, UGRGB, ENCODER |
| Mpad12 | 0x00AA | 0xAAAA | Hotswap | Atmel atmega32u4 | RGB, UGRGB, JOYSTICK, ENCODER, OLED |
| split69 | 0x00AA | 0xAAAB | Solder | Atmel atmega32u4 | SPLIT, UGRGB, OLED, ENCODER |

| GH60 | 0xFEED | 0x6060 | Hotswap | ST stm32f103/f103 | RGB |
# ZhaQian library
这是一个集合了许多简单的但可能在不同键盘上重复用到功能的库.
- Alt Tab Marco
Expand Down
2 changes: 2 additions & 0 deletions keyboards/zhaqian/s80/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
#undef STM32_HSECLK
#define STM32_HSECLK 8000000

#undef STM32F103xB
#define STM32F103x8
8 changes: 6 additions & 2 deletions keyboards/zhaqian/s80/rules.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# MCU name
MCU = STM32F103
MCU_LDSCRIPT = STM32F103x8_uf2
FIRMWARE_FORMAT = uf2
BOARD = STM32_F103_STM32DUINO

# Bootloader selection
BOOTLOADER = tinyuf2

BOOTLOADER = custom
# Build Options
# comment out to disable the options.
#
Expand All @@ -16,5 +18,7 @@ SLEEP_LED_ENABLE = no
NKRO_ENABLE = yes
RGBLIGHT_ENABLE = no
KEYBOARD_SHARED_EP = no
LTO_ENABLE = yes

OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE
SRC += uf2_boot.c
30 changes: 30 additions & 0 deletions keyboards/zhaqian/s80/uf2_boot.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright 2022 ZhaQian
*
* 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/>.
*/

#include "bootloader.h"

#include <ch.h>

#define MAGIC_BOOT 0x544F4F42UL
#define MAGIC_REG *(volatile uint32_t*)0x20004000

void bootloader_jump(void) {
MAGIC_REG = MAGIC_BOOT;
NVIC_SystemReset();
}

void enter_bootloader_mode_if_requested(void) {}

2 changes: 2 additions & 0 deletions keyboards/zhaqian/sp67/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
#undef STM32_HSECLK
#define STM32_HSECLK 8000000

#undef STM32F103xB
#define STM32F103x8
7 changes: 6 additions & 1 deletion keyboards/zhaqian/sp67/rules.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# MCU name
MCU = STM32F103
MCU_LDSCRIPT = STM32F103x8_uf2
FIRMWARE_FORMAT = uf2
BOARD = STM32_F103_STM32DUINO

# Bootloader selection
BOOTLOADER = tinyuf2
BOOTLOADER = custom

# Build Options
# comment out to disable the options.
Expand All @@ -16,5 +19,7 @@ SLEEP_LED_ENABLE = no
NKRO_ENABLE = yes
RGBLIGHT_ENABLE = no
KEYBOARD_SHARED_EP = no
LTO_ENABLE = yes

OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE
SRC += uf2_boot.c
30 changes: 30 additions & 0 deletions keyboards/zhaqian/sp67/uf2_boot.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright 2022 ZhaQian
*
* 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/>.
*/

#include "bootloader.h"

#include <ch.h>

#define MAGIC_BOOT 0x544F4F42UL
#define MAGIC_REG *(volatile uint32_t*)0x20004000

void bootloader_jump(void) {
MAGIC_REG = MAGIC_BOOT;
NVIC_SystemReset();
}

void enter_bootloader_mode_if_requested(void) {}

7 changes: 5 additions & 2 deletions keyboards/zhaqian/zq50/rules.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# MCU name
MCU = STM32F103
MCU_LDSCRIPT = STM32F103xB_uf2
FIRMWARE_FORMAT = uf2
BOARD = STM32_F103_STM32DUINO

# Bootloader selection
BOOTLOADER = tinyuf2
BOOTLOADER = custom

# Build Options
# comment out to disable the options.
Expand All @@ -16,7 +18,8 @@ COMMAND_ENABLE = no
SLEEP_LED_ENABLE = no
NKRO_ENABLE = yes
RGBLIGHT_ENABLE = no
LTO_ENABLE = yes

OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE

SRC += uf2_boot.c

30 changes: 30 additions & 0 deletions keyboards/zhaqian/zq50/uf2_boot.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright 2022 ZhaQian
*
* 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/>.
*/

#include "bootloader.h"

#include <ch.h>

#define MAGIC_BOOT 0x544F4F42UL
#define MAGIC_REG *(volatile uint32_t*)0x20004000

void bootloader_jump(void) {
MAGIC_REG = MAGIC_BOOT;
NVIC_SystemReset();
}

void enter_bootloader_mode_if_requested(void) {}

Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,3 @@ REGION_ALIAS("HEAP_RAM", ram0);

/* Generic rules inclusion.*/
INCLUDE rules.ld

/* TinyUF2 bootloader reset support */
_board_dfu_dbl_tap = ORIGIN(ram0) + 20k - 4; /* this is based off the linker file for tinyuf2 */
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,4 @@ REGION_ALIAS("HEAP_RAM", ram0);
/* Generic rules inclusion.*/
INCLUDE rules.ld

/* TinyUF2 bootloader reset support */
_board_dfu_dbl_tap = ORIGIN(ram0) + 20k - 4; /* this is based off the linker file for tinyuf2 */

Loading

0 comments on commit 9d33290

Please sign in to comment.