~ruther/qmk_firmware

0206bd9df31521fcfd764c3dd4cff383e4957151 — dvermd 3 years ago b6757d2
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 <fauxpark@gmail.com>

* Apply suggested change

Co-authored-by: Ryan <fauxpark@gmail.com>

* Apply suggested change

Co-authored-by: Ryan <fauxpark@gmail.com>

* Apply suggested change

Co-authored-by: Ryan <fauxpark@gmail.com>

* Apply suggested change

Co-authored-by: Ryan <fauxpark@gmail.com>

* splittest/bluepill: improve documentation

Co-authored-by: Ryan <fauxpark@gmail.com>
A keyboards/handwired/splittest/bluepill/chconf.h => keyboards/handwired/splittest/bluepill/chconf.h +23 -0
@@ 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 <http://www.gnu.org/licenses/>.
 */

#pragma once

#define CH_CFG_ST_TIMEDELTA 0

#define CH_CFG_USE_CONDVARS_TIMEOUT FALSE

#include_next <chconf.h>

A keyboards/handwired/splittest/bluepill/config.h => keyboards/handwired/splittest/bluepill/config.h +16 -0
@@ 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

A keyboards/handwired/splittest/bluepill/halconf.h => keyboards/handwired/splittest/bluepill/halconf.h +6 -0
@@ 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 <halconf.h>

A keyboards/handwired/splittest/bluepill/mcuconf.h => keyboards/handwired/splittest/bluepill/mcuconf.h +11 -0
@@ 0,0 1,11 @@
#pragma once

#include_next <mcuconf.h>

// 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

A keyboards/handwired/splittest/bluepill/post_config.h => keyboards/handwired/splittest/bluepill/post_config.h +38 -0
@@ 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

A keyboards/handwired/splittest/bluepill/readme.md => keyboards/handwired/splittest/bluepill/readme.md +65 -0
@@ 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

A keyboards/handwired/splittest/bluepill/rules.mk => keyboards/handwired/splittest/bluepill/rules.mk +10 -0
@@ 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

A keyboards/handwired/splittest/keymaps/bitbang/config.h => keyboards/handwired/splittest/keymaps/bitbang/config.h +18 -0
@@ 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

A keyboards/handwired/splittest/keymaps/bitbang/keymap.c => keyboards/handwired/splittest/keymaps/bitbang/keymap.c +11 -0
@@ 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

A keyboards/handwired/splittest/keymaps/bitbang/rules.mk => keyboards/handwired/splittest/keymaps/bitbang/rules.mk +1 -0
@@ 0,0 1,1 @@
SERIAL_DRIVER = bitbang

A keyboards/handwired/splittest/keymaps/serial_fullduplex/config.h => keyboards/handwired/splittest/keymaps/serial_fullduplex/config.h +8 -0
@@ 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

A keyboards/handwired/splittest/keymaps/serial_fullduplex/halconf.h => keyboards/handwired/splittest/keymaps/serial_fullduplex/halconf.h +2 -0
@@ 0,0 1,2 @@
#define HAL_USE_SERIAL TRUE
#include_next <halconf.h>

A keyboards/handwired/splittest/keymaps/serial_fullduplex/keymap.c => keyboards/handwired/splittest/keymaps/serial_fullduplex/keymap.c +11 -0
@@ 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;
}

A keyboards/handwired/splittest/keymaps/serial_fullduplex/rules.mk => keyboards/handwired/splittest/keymaps/serial_fullduplex/rules.mk +1 -0
@@ 0,0 1,1 @@
SERIAL_DRIVER = usart

A keyboards/handwired/splittest/keymaps/serial_halfduplex/config.h => keyboards/handwired/splittest/keymaps/serial_halfduplex/config.h +8 -0
@@ 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

A keyboards/handwired/splittest/keymaps/serial_halfduplex/halconf.h => keyboards/handwired/splittest/keymaps/serial_halfduplex/halconf.h +2 -0
@@ 0,0 1,2 @@
#define HAL_USE_SERIAL TRUE
#include_next <halconf.h>

A keyboards/handwired/splittest/keymaps/serial_halfduplex/keymap.c => keyboards/handwired/splittest/keymaps/serial_halfduplex/keymap.c +11 -0
@@ 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;
}

A keyboards/handwired/splittest/keymaps/serial_halfduplex/rules.mk => keyboards/handwired/splittest/keymaps/serial_halfduplex/rules.mk +1 -0
@@ 0,0 1,1 @@
SERIAL_DRIVER = usart

M keyboards/handwired/splittest/promicro/rules.mk => keyboards/handwired/splittest/promicro/rules.mk +2 -0
@@ 3,3 3,5 @@ MCU = atmega32u4

# Bootloader selection
BOOTLOADER = caterina

RGBLIGHT_ENABLE = yes

M keyboards/handwired/splittest/rules.mk => keyboards/handwired/splittest/rules.mk +1 -1
@@ 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


M keyboards/handwired/splittest/teensy_2/rules.mk => keyboards/handwired/splittest/teensy_2/rules.mk +2 -0
@@ 3,3 3,5 @@ MCU = atmega32u4

# Bootloader selection
BOOTLOADER = halfkay

RGBLIGHT_ENABLE = yes