From 930f6fa5a5e7e1dc2d05f3e9186abe1331552053 Mon Sep 17 00:00:00 2001 From: HorrorTroll Date: Sun, 14 Aug 2022 09:07:39 +0700 Subject: [PATCH] Add STM32 Mini V2 board into onekey folder --- .../handwired/onekey/stm32_mini_v2/board.h | 20 +++++++ .../handwired/onekey/stm32_mini_v2/config.h | 59 +++++++++++++++++++ .../handwired/onekey/stm32_mini_v2/halconf.h | 30 ++++++++++ .../handwired/onekey/stm32_mini_v2/mcuconf.h | 33 +++++++++++ .../handwired/onekey/stm32_mini_v2/readme.md | 5 ++ .../handwired/onekey/stm32_mini_v2/rules.mk | 19 ++++++ 6 files changed, 166 insertions(+) create mode 100644 keyboards/handwired/onekey/stm32_mini_v2/board.h create mode 100644 keyboards/handwired/onekey/stm32_mini_v2/config.h create mode 100644 keyboards/handwired/onekey/stm32_mini_v2/halconf.h create mode 100644 keyboards/handwired/onekey/stm32_mini_v2/mcuconf.h create mode 100644 keyboards/handwired/onekey/stm32_mini_v2/readme.md create mode 100644 keyboards/handwired/onekey/stm32_mini_v2/rules.mk diff --git a/keyboards/handwired/onekey/stm32_mini_v2/board.h b/keyboards/handwired/onekey/stm32_mini_v2/board.h new file mode 100644 index 00000000000..edd68f15ae9 --- /dev/null +++ b/keyboards/handwired/onekey/stm32_mini_v2/board.h @@ -0,0 +1,20 @@ +/* Copyright 2022 HorrorTroll + * + * 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 . + */ + +#include_next + +#undef STM32F103xB +#define STM32F103xE diff --git a/keyboards/handwired/onekey/stm32_mini_v2/config.h b/keyboards/handwired/onekey/stm32_mini_v2/config.h new file mode 100644 index 00000000000..a29f549cf84 --- /dev/null +++ b/keyboards/handwired/onekey/stm32_mini_v2/config.h @@ -0,0 +1,59 @@ +/* Copyright 2022 HorrorTroll + * + * 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 + +#include "config_common.h" + +#define PRODUCT Onekey STM32 Mini v2 STM32F103RC + +/* Key matrix pins */ +#define MATRIX_COL_PINS { B0 } +#define MATRIX_ROW_PINS { B1 } +#define UNUSED_PINS + +// SPI configuration +#define SPI_DRIVER SPID1 +#define SPI_SCK_PIN A5 +#define SPI_MOSI_PIN A7 +#define SPI_MISO_PIN A6 + +// Flash configuration +#define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN A2 +#define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR 16 +#define EXTERNAL_FLASH_PAGE_SIZE 256 +#define EXTERNAL_FLASH_SECTOR_SIZE 4096 +#define EXTERNAL_FLASH_BLOCK_SIZE 4096 +#define EXTERNAL_FLASH_SIZE (256 * 1024) // 2M-bit flash size + +// Wear-leveling driver configuration +#define WEAR_LEVELING_LOGICAL_SIZE 1024 +#define WEAR_LEVELING_BACKING_SIZE (WEAR_LEVELING_LOGICAL_SIZE * 2) + +// ADC configuration +#define ADC_PIN A0 + +#ifdef BACKLIGHT_ENABLE + /* Backlight config */ + #define BACKLIGHT_PIN A0 + #define BACKLIGHT_PWM_DRIVER PWMD2 + #define BACKLIGHT_PWM_CHANNEL 1 +#endif + +#ifdef RGB_MATRIX_ENABLE + /* RGB Matrix config */ + #define RGB_DI_PIN A1 +#endif diff --git a/keyboards/handwired/onekey/stm32_mini_v2/halconf.h b/keyboards/handwired/onekey/stm32_mini_v2/halconf.h new file mode 100644 index 00000000000..70adcdf5211 --- /dev/null +++ b/keyboards/handwired/onekey/stm32_mini_v2/halconf.h @@ -0,0 +1,30 @@ +/* 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 keyboards/handwired/onekey/bluepill/halconf.h -r platforms/chibios/common/configs/halconf.h` + */ + +#pragma once + +#define HAL_USE_PWM TRUE + +#define HAL_USE_SPI TRUE +#define SPI_USE_WAIT TRUE +#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD + +#include_next diff --git a/keyboards/handwired/onekey/stm32_mini_v2/mcuconf.h b/keyboards/handwired/onekey/stm32_mini_v2/mcuconf.h new file mode 100644 index 00000000000..cf2528c5608 --- /dev/null +++ b/keyboards/handwired/onekey/stm32_mini_v2/mcuconf.h @@ -0,0 +1,33 @@ +/* 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 keyboards/handwired/onekey/bluepill/mcuconf.h -r platforms/chibios/STM32_F103_STM32DUINO/configs/mcuconf.h` + */ + +#pragma once + +#include_next + +#undef STM32_PWM_USE_TIM2 +#define STM32_PWM_USE_TIM2 TRUE + +#undef STM32_SPI_USE_SPI1 +#define STM32_SPI_USE_SPI1 TRUE + +#undef STM32_SPI_USE_SPI2 +#define STM32_SPI_USE_SPI2 FALSE diff --git a/keyboards/handwired/onekey/stm32_mini_v2/readme.md b/keyboards/handwired/onekey/stm32_mini_v2/readme.md new file mode 100644 index 00000000000..62234104910 --- /dev/null +++ b/keyboards/handwired/onekey/stm32_mini_v2/readme.md @@ -0,0 +1,5 @@ +# STM32 Mini V2 STM32F103RCxx onekey + +* Supported hardware: STM32 Mini V2 boards with the STM32F103R**C**xx chips + +To trigger keypress, short together pins *B0* and *B1*. diff --git a/keyboards/handwired/onekey/stm32_mini_v2/rules.mk b/keyboards/handwired/onekey/stm32_mini_v2/rules.mk new file mode 100644 index 00000000000..28588c53776 --- /dev/null +++ b/keyboards/handwired/onekey/stm32_mini_v2/rules.mk @@ -0,0 +1,19 @@ +# MCU name +MCU = STM32F103 + +# Bootloader selection +# Cannot use `BOOTLOADER = stm32duino` due to the need to override +# `MCU_LDSCRIPT`, therefore all parameters need to be specified here manually. +OPT_DEFS += -DBOOTLOADER_STM32DUINO +MCU_LDSCRIPT = STM32F103xC_stm32duino_bootloader +BOARD = STM32_F103_STM32DUINO +BOOTLOADER_TYPE = stm32duino +DFU_ARGS = -d 1EAF:0003 -a 2 -R +DFU_SUFFIX_ARGS = -v 1EAF -p 0003 + +# Enter lower-power sleep mode when on the ChibiOS idle thread +OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE + +# Wear-levelling driver +EEPROM_DRIVER = wear_leveling +WEAR_LEVELING_DRIVER = spi_flash