From 0206bd9df31521fcfd764c3dd4cff383e4957151 Mon Sep 17 00:00:00 2001 From: dvermd <315743+dvermd@users.noreply.github.com> Date: Wed, 3 Aug 2022 10:31:37 +0200 Subject: add bluepill mcu to splittest (#16959) * add bluepill mcu to splittest * fix typo * refactoring * mcu config goes to mcuconf.h of keyboard * keymap specific config goes to keymap config.h * keyboard specific depending of keymap goes to post_config.h * Apply suggested change Co-authored-by: Ryan * Apply suggested change Co-authored-by: Ryan * Apply suggested change Co-authored-by: Ryan * Apply suggested change Co-authored-by: Ryan * Apply suggested change Co-authored-by: Ryan * splittest/bluepill: improve documentation Co-authored-by: Ryan --- keyboards/handwired/splittest/bluepill/chconf.h | 23 ++++++++ keyboards/handwired/splittest/bluepill/config.h | 16 ++++++ keyboards/handwired/splittest/bluepill/halconf.h | 6 ++ keyboards/handwired/splittest/bluepill/mcuconf.h | 11 ++++ .../handwired/splittest/bluepill/post_config.h | 38 +++++++++++++ keyboards/handwired/splittest/bluepill/readme.md | 65 ++++++++++++++++++++++ keyboards/handwired/splittest/bluepill/rules.mk | 10 ++++ 7 files changed, 169 insertions(+) create mode 100644 keyboards/handwired/splittest/bluepill/chconf.h create mode 100644 keyboards/handwired/splittest/bluepill/config.h create mode 100644 keyboards/handwired/splittest/bluepill/halconf.h create mode 100644 keyboards/handwired/splittest/bluepill/mcuconf.h create mode 100644 keyboards/handwired/splittest/bluepill/post_config.h create mode 100644 keyboards/handwired/splittest/bluepill/readme.md create mode 100644 keyboards/handwired/splittest/bluepill/rules.mk (limited to 'keyboards/handwired/splittest/bluepill') diff --git a/keyboards/handwired/splittest/bluepill/chconf.h b/keyboards/handwired/splittest/bluepill/chconf.h new file mode 100644 index 0000000000..73c7d64e3a --- /dev/null +++ b/keyboards/handwired/splittest/bluepill/chconf.h @@ -0,0 +1,23 @@ +/* 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 . + */ + +#pragma once + +#define CH_CFG_ST_TIMEDELTA 0 + +#define CH_CFG_USE_CONDVARS_TIMEOUT FALSE + +#include_next diff --git a/keyboards/handwired/splittest/bluepill/config.h b/keyboards/handwired/splittest/bluepill/config.h new file mode 100644 index 0000000000..92766b3de4 --- /dev/null +++ b/keyboards/handwired/splittest/bluepill/config.h @@ -0,0 +1,16 @@ +// Copyright 2022 dvermd (@dvermd) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "config_common.h" + +// wiring of each half +#define MATRIX_ROW_PINS { B10 } +#define MATRIX_COL_PINS { B1 } + +#define SPLIT_HAND_PIN A7 + +#if !(defined(USE_SDI1_ON_STANDARD_ROLE_PINS) || defined(USE_SDI1_ON_ALTERNATE_ROLE_PINS) || defined(USE_SDI2)) + #define USE_SDI1_ON_STANDARD_ROLE_PINS +#endif \ No newline at end of file diff --git a/keyboards/handwired/splittest/bluepill/halconf.h b/keyboards/handwired/splittest/bluepill/halconf.h new file mode 100644 index 0000000000..d85c8b842e --- /dev/null +++ b/keyboards/handwired/splittest/bluepill/halconf.h @@ -0,0 +1,6 @@ +/* Needed for serial bitbang, half-duplex and full-duplex */ +#define HAL_USE_PAL TRUE +#define PAL_USE_WAIT TRUE +#define PAL_USE_CALLBACKS TRUE + +#include_next diff --git a/keyboards/handwired/splittest/bluepill/mcuconf.h b/keyboards/handwired/splittest/bluepill/mcuconf.h new file mode 100644 index 0000000000..875819537f --- /dev/null +++ b/keyboards/handwired/splittest/bluepill/mcuconf.h @@ -0,0 +1,11 @@ +#pragma once + +#include_next + +// These are needed if the communication is on the SD1 USART, either with standard or alternate pins +#undef STM32_SERIAL_USE_USART1 +#define STM32_SERIAL_USE_USART1 TRUE + +// These are needed if the communication is on the SD2 USART, either with standard or alternate pins +#undef STM32_SERIAL_USE_USART2 +#define STM32_SERIAL_USE_USART2 TRUE diff --git a/keyboards/handwired/splittest/bluepill/post_config.h b/keyboards/handwired/splittest/bluepill/post_config.h new file mode 100644 index 0000000000..b866805a64 --- /dev/null +++ b/keyboards/handwired/splittest/bluepill/post_config.h @@ -0,0 +1,38 @@ + +#if defined(SPLIT_BITBANG) + + #define SOFT_SERIAL_PIN B8 + +#elif defined(SPLIT_SERIAL_HALFDUPLEX) + + #if defined(USE_SDI1_ON_STANDARD_ROLE_PINS) + #define SOFT_SERIAL_PIN A9 + #elif defined(USE_SDI1_ON_ALTERNATE_ROLE_PINS) + #define SOFT_SERIAL_PIN B6 + #define USART1_REMAP // Remap USART TX and RX pins on STM32F103 MCUs + #elif defined(USE_SDI2) + #define SOFT_SERIAL_PIN A2 + #define SERIAL_USART_DRIVER SD2 // USART driver of TX and RX pin. default: SD1 + #else + #error "splittest serial_halfduplex keymap is missing a configuration (USE_SDI1_ON_STANDARD_ROLE_PINS, USE_SDI1_ON_ALTERNATE_ROLE_PINS, USE_SDI2)" + #endif + +#elif defined(SPLIT_SERIAL_FULLDUPLEX) + + #define SERIAL_USART_FULL_DUPLEX // Enable full duplex operation mode. + + #if defined(USE_SDI1_ON_STANDARD_ROLE_PINS) + #define SOFT_SERIAL_PIN A9 + #define SERIAL_USART_RX_PIN A10 // USART RX pin + #elif defined(USE_SDI1_ON_ALTERNATE_ROLE_PINS) + #define SOFT_SERIAL_PIN B6 + #define SERIAL_USART_RX_PIN B7 // USART RX pin + #define USART1_REMAP // Remap USART TX and RX pins on STM32F103 MCUs + #elif defined(USE_SDI2) + #define SOFT_SERIAL_PIN A2 + #define SERIAL_USART_RX_PIN A3 // USART RX pin + #define SERIAL_USART_DRIVER SD2 // USART driver of TX and RX pin. default: SD1 + #else + #error "splittest serial_fullduplex keymap is missing a configuration (USE_SDI1_ON_STANDARD_ROLE_PINS, USE_SDI1_ON_ALTERNATE_ROLE_PINS, USE_SDI2)" + #endif +#endif diff --git a/keyboards/handwired/splittest/bluepill/readme.md b/keyboards/handwired/splittest/bluepill/readme.md new file mode 100644 index 0000000000..381aa6ba3a --- /dev/null +++ b/keyboards/handwired/splittest/bluepill/readme.md @@ -0,0 +1,65 @@ +# bluepill splittest + +This is the splittest example for the bluepill MCU. +To trigger keypress, short together pins _B10_ and _B1_. + +## Keyboard Configuration + +The type of communication (bitbang, serial (half/full duplex)) is set by the keymap `config.h` file with variables with `SPLIT_` prefix. +So this example uses: + +- `config.h` to set which SDI to use for serial. Either define `USE_SDI1_ON_STANDARD_ROLE_PINS`, `USE_SDI1_ON_ALTERNATE_ROLE_PINS` or `USE_SDI2` before the `#ifdef` that configures the default case when none of these variable is defined. +- `post_config.h` for defining the communication pins between the halves once the keymap is configured. + +On your keyboard, you most likely will only use `config.h` because you'd have already chosen your communication scheme: serial type, SDI, pins. + +## Wiring + +### Switches + +- Add switches to both Bluepills across B10 and B1 pins + +### Handedness + +Have a look at the [handedness documentation](https://docs.qmk.fm/#/feature_split_keyboard?id=setting-handedness) + +- Add pull-up resistor to left side between VCC and A7 +- Add pull-down resistors to right side between GND and A7 + +### Send power to the other half + +- Connect the following pins on both sides together: GND, VCC + +### Halves data connection + +Choose one of the connection type + +#### serial - bitbang + +- Connect the B8 pins on both sides together + +#### serial - usart half duplex + +Check the [documentation](https://docs.qmk.fm/#/serial_driver?id=usart-half-duplex) to determine the pull-up resistor. + +- To use the default usart (USART1) with the standard role pins, + - Connect the A9 pins on both sides together and to add a pull-up resistor on one of these pins + - Define USE_SDI1_ON_STANDARD_ROLE_PINS in config.h +- To use the default usart (USART1) with the alternate role pins, + - Connect the B6 pins on both sides together and to add a pull-up resistor on one of these pins + - Define USE_SDI1_ON_ALTERNATE_ROLE_PINS in config.h +- To use the usart2 (USART2) pins, + - Connect the A2 pins on both sides together and to add a pull-up resistor on one of these pins + - Define USE_SDI2 in config.h + +#### serial - usart full duplex + +- To use the default usart (USART1) with the standard role pins, + - Connect the mpins on A9, A10 one to the other on each side + - Define USE_SDI1_ON_STANDARD_ROLE_PINS in config.h +- To use the default usart (USART1) with the alternate role pins, + - Connect the pins B6, B7 one to the other on each side + - Define USE_SDI1_ON_ALTERNATE_ROLE_PINS in config.h +- To use the usart2 (USART2) pins, + - Connect the pins A2, A3 one to the other on each side + - Define USE_SDI2 in config.h diff --git a/keyboards/handwired/splittest/bluepill/rules.mk b/keyboards/handwired/splittest/bluepill/rules.mk new file mode 100644 index 0000000000..1d2ff9419e --- /dev/null +++ b/keyboards/handwired/splittest/bluepill/rules.mk @@ -0,0 +1,10 @@ +# MCU name +MCU = STM32F103 + +# Bootloader selection +BOOTLOADER = stm32duino + +CONSOLE_ENABLE = yes + +# Enter lower-power sleep mode when on the ChibiOS idle thread +OPT_DEFS += -DCORTEX_ENABLE_WFI_IDLE=TRUE -- cgit v1.2.3