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 ++++ .../handwired/splittest/keymaps/bitbang/config.h | 18 ++++++ .../handwired/splittest/keymaps/bitbang/keymap.c | 11 ++++ .../handwired/splittest/keymaps/bitbang/rules.mk | 1 + .../splittest/keymaps/serial_fullduplex/config.h | 8 +++ .../splittest/keymaps/serial_fullduplex/halconf.h | 2 + .../splittest/keymaps/serial_fullduplex/keymap.c | 11 ++++ .../splittest/keymaps/serial_fullduplex/rules.mk | 1 + .../splittest/keymaps/serial_halfduplex/config.h | 8 +++ .../splittest/keymaps/serial_halfduplex/halconf.h | 2 + .../splittest/keymaps/serial_halfduplex/keymap.c | 11 ++++ .../splittest/keymaps/serial_halfduplex/rules.mk | 1 + keyboards/handwired/splittest/promicro/rules.mk | 2 + keyboards/handwired/splittest/rules.mk | 2 +- keyboards/handwired/splittest/teensy_2/rules.mk | 2 + 21 files changed, 248 insertions(+), 1 deletion(-) 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 create mode 100644 keyboards/handwired/splittest/keymaps/bitbang/config.h create mode 100644 keyboards/handwired/splittest/keymaps/bitbang/keymap.c create mode 100644 keyboards/handwired/splittest/keymaps/bitbang/rules.mk create mode 100644 keyboards/handwired/splittest/keymaps/serial_fullduplex/config.h create mode 100644 keyboards/handwired/splittest/keymaps/serial_fullduplex/halconf.h create mode 100644 keyboards/handwired/splittest/keymaps/serial_fullduplex/keymap.c create mode 100644 keyboards/handwired/splittest/keymaps/serial_fullduplex/rules.mk create mode 100644 keyboards/handwired/splittest/keymaps/serial_halfduplex/config.h create mode 100644 keyboards/handwired/splittest/keymaps/serial_halfduplex/halconf.h create mode 100644 keyboards/handwired/splittest/keymaps/serial_halfduplex/keymap.c create mode 100644 keyboards/handwired/splittest/keymaps/serial_halfduplex/rules.mk (limited to 'keyboards/handwired') 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 diff --git a/keyboards/handwired/splittest/keymaps/bitbang/config.h b/keyboards/handwired/splittest/keymaps/bitbang/config.h new file mode 100644 index 0000000000..c21a363855 --- /dev/null +++ b/keyboards/handwired/splittest/keymaps/bitbang/config.h @@ -0,0 +1,18 @@ +// Copyright 2022 dvermd (@dvermd) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "config_common.h" + +#define SPLIT_BITBANG + +#define FORCED_SYNC_THROTTLE_MS 100 + +#define SELECT_SOFT_SERIAL_SPEED 3 // or 0, 1, 2, 4, 5 + // 0: about 189kbps (Experimental only) + // 1: about 137kbps (default) + // 2: about 75kbps + // 3: about 39kbps + // 4: about 26kbps + // 5: about 20kbps diff --git a/keyboards/handwired/splittest/keymaps/bitbang/keymap.c b/keyboards/handwired/splittest/keymaps/bitbang/keymap.c new file mode 100644 index 0000000000..9875000319 --- /dev/null +++ b/keyboards/handwired/splittest/keymaps/bitbang/keymap.c @@ -0,0 +1,11 @@ +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {[0] = LAYOUT(KC_L, KC_R)}; + +void keyboard_post_init_user(void) { + // Customise these values to desired behaviour + debug_enable = true; + debug_matrix = true; + debug_keyboard = true; + // debug_mouse=true; +} \ No newline at end of file diff --git a/keyboards/handwired/splittest/keymaps/bitbang/rules.mk b/keyboards/handwired/splittest/keymaps/bitbang/rules.mk new file mode 100644 index 0000000000..a4f16a0b6b --- /dev/null +++ b/keyboards/handwired/splittest/keymaps/bitbang/rules.mk @@ -0,0 +1 @@ +SERIAL_DRIVER = bitbang diff --git a/keyboards/handwired/splittest/keymaps/serial_fullduplex/config.h b/keyboards/handwired/splittest/keymaps/serial_fullduplex/config.h new file mode 100644 index 0000000000..b83dc43a1f --- /dev/null +++ b/keyboards/handwired/splittest/keymaps/serial_fullduplex/config.h @@ -0,0 +1,8 @@ +// Copyright 2022 dvermd (@dvermd) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "config_common.h" + +#define SPLIT_SERIAL_FULLDUPLEX diff --git a/keyboards/handwired/splittest/keymaps/serial_fullduplex/halconf.h b/keyboards/handwired/splittest/keymaps/serial_fullduplex/halconf.h new file mode 100644 index 0000000000..35ae5bf214 --- /dev/null +++ b/keyboards/handwired/splittest/keymaps/serial_fullduplex/halconf.h @@ -0,0 +1,2 @@ +#define HAL_USE_SERIAL TRUE +#include_next diff --git a/keyboards/handwired/splittest/keymaps/serial_fullduplex/keymap.c b/keyboards/handwired/splittest/keymaps/serial_fullduplex/keymap.c new file mode 100644 index 0000000000..84919f53a7 --- /dev/null +++ b/keyboards/handwired/splittest/keymaps/serial_fullduplex/keymap.c @@ -0,0 +1,11 @@ +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {[0] = LAYOUT(KC_L, KC_R)}; + +void keyboard_post_init_user(void) { + // Customise these values to desired behaviour + debug_enable = true; + debug_matrix = true; + debug_keyboard = true; + // debug_mouse=true; +} diff --git a/keyboards/handwired/splittest/keymaps/serial_fullduplex/rules.mk b/keyboards/handwired/splittest/keymaps/serial_fullduplex/rules.mk new file mode 100644 index 0000000000..c6e2988321 --- /dev/null +++ b/keyboards/handwired/splittest/keymaps/serial_fullduplex/rules.mk @@ -0,0 +1 @@ +SERIAL_DRIVER = usart diff --git a/keyboards/handwired/splittest/keymaps/serial_halfduplex/config.h b/keyboards/handwired/splittest/keymaps/serial_halfduplex/config.h new file mode 100644 index 0000000000..96dcf0dc42 --- /dev/null +++ b/keyboards/handwired/splittest/keymaps/serial_halfduplex/config.h @@ -0,0 +1,8 @@ +// Copyright 2022 dvermd (@dvermd) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "config_common.h" + +#define SPLIT_SERIAL_HALFDUPLEX diff --git a/keyboards/handwired/splittest/keymaps/serial_halfduplex/halconf.h b/keyboards/handwired/splittest/keymaps/serial_halfduplex/halconf.h new file mode 100644 index 0000000000..35ae5bf214 --- /dev/null +++ b/keyboards/handwired/splittest/keymaps/serial_halfduplex/halconf.h @@ -0,0 +1,2 @@ +#define HAL_USE_SERIAL TRUE +#include_next diff --git a/keyboards/handwired/splittest/keymaps/serial_halfduplex/keymap.c b/keyboards/handwired/splittest/keymaps/serial_halfduplex/keymap.c new file mode 100644 index 0000000000..84919f53a7 --- /dev/null +++ b/keyboards/handwired/splittest/keymaps/serial_halfduplex/keymap.c @@ -0,0 +1,11 @@ +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {[0] = LAYOUT(KC_L, KC_R)}; + +void keyboard_post_init_user(void) { + // Customise these values to desired behaviour + debug_enable = true; + debug_matrix = true; + debug_keyboard = true; + // debug_mouse=true; +} diff --git a/keyboards/handwired/splittest/keymaps/serial_halfduplex/rules.mk b/keyboards/handwired/splittest/keymaps/serial_halfduplex/rules.mk new file mode 100644 index 0000000000..c6e2988321 --- /dev/null +++ b/keyboards/handwired/splittest/keymaps/serial_halfduplex/rules.mk @@ -0,0 +1 @@ +SERIAL_DRIVER = usart diff --git a/keyboards/handwired/splittest/promicro/rules.mk b/keyboards/handwired/splittest/promicro/rules.mk index cf663a7ed6..d29dbc8596 100644 --- a/keyboards/handwired/splittest/promicro/rules.mk +++ b/keyboards/handwired/splittest/promicro/rules.mk @@ -3,3 +3,5 @@ MCU = atmega32u4 # Bootloader selection BOOTLOADER = caterina + +RGBLIGHT_ENABLE = yes diff --git a/keyboards/handwired/splittest/rules.mk b/keyboards/handwired/splittest/rules.mk index b33e198bbd..18300431b2 100644 --- a/keyboards/handwired/splittest/rules.mk +++ b/keyboards/handwired/splittest/rules.mk @@ -9,7 +9,7 @@ COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = no # Enable N-Key Rollover BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality AUDIO_ENABLE = no # Audio output -RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. +RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow SPLIT_KEYBOARD = yes diff --git a/keyboards/handwired/splittest/teensy_2/rules.mk b/keyboards/handwired/splittest/teensy_2/rules.mk index 320633f80f..a88fa054ee 100644 --- a/keyboards/handwired/splittest/teensy_2/rules.mk +++ b/keyboards/handwired/splittest/teensy_2/rules.mk @@ -3,3 +3,5 @@ MCU = atmega32u4 # Bootloader selection BOOTLOADER = halfkay + +RGBLIGHT_ENABLE = yes -- cgit v1.2.1