From 2337cd1186e6a7b3f085cdafac5c1da87074015b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reibl=20J=C3=A1nos=20D=C3=A1niel?=
 <janos.daniel.reibl@protonmail.com>
Date: Wed, 8 Nov 2023 09:31:06 +0100
Subject: [PATCH] Add riblee handwired split keyboard (#22277)

---
 keyboards/handwired/riblee_split/config.h     |  11 ++
 keyboards/handwired/riblee_split/halconf.h    |   8 +
 keyboards/handwired/riblee_split/info.json    | 108 ++++++++++++
 .../riblee_split/keymaps/default/keymap.c     | 155 ++++++++++++++++++
 keyboards/handwired/riblee_split/mcuconf.h    |   7 +
 keyboards/handwired/riblee_split/readme.md    |  24 +++
 keyboards/handwired/riblee_split/rules.mk     |   1 +
 7 files changed, 314 insertions(+)
 create mode 100644 keyboards/handwired/riblee_split/config.h
 create mode 100644 keyboards/handwired/riblee_split/halconf.h
 create mode 100644 keyboards/handwired/riblee_split/info.json
 create mode 100644 keyboards/handwired/riblee_split/keymaps/default/keymap.c
 create mode 100644 keyboards/handwired/riblee_split/mcuconf.h
 create mode 100644 keyboards/handwired/riblee_split/readme.md
 create mode 100644 keyboards/handwired/riblee_split/rules.mk

diff --git a/keyboards/handwired/riblee_split/config.h b/keyboards/handwired/riblee_split/config.h
new file mode 100644
index 0000000000..c3b0720ba5
--- /dev/null
+++ b/keyboards/handwired/riblee_split/config.h
@@ -0,0 +1,11 @@
+// Copyright 2023 Daniel Reibl (@riblee)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+// If the pin is high, then the controller assumes it is the left hand, and if it’s low, it’s assumed to be the right side.
+#define SPLIT_HAND_PIN C15
+
+#define SERIAL_USART_FULL_DUPLEX
+#define SERIAL_USART_TX_PIN B6
+#define SERIAL_USART_RX_PIN B7
diff --git a/keyboards/handwired/riblee_split/halconf.h b/keyboards/handwired/riblee_split/halconf.h
new file mode 100644
index 0000000000..1d5c3fd700
--- /dev/null
+++ b/keyboards/handwired/riblee_split/halconf.h
@@ -0,0 +1,8 @@
+// Copyright 2023 Daniel Reibl (@riblee)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#define HAL_USE_SERIAL TRUE
+
+#include_next <halconf.h>
diff --git a/keyboards/handwired/riblee_split/info.json b/keyboards/handwired/riblee_split/info.json
new file mode 100644
index 0000000000..49b5ca3a54
--- /dev/null
+++ b/keyboards/handwired/riblee_split/info.json
@@ -0,0 +1,108 @@
+{
+    "manufacturer": "Riblee",
+    "keyboard_name": "Split",
+    "maintainer": "riblee",
+    "bootloader": "stm32-dfu",
+    "diode_direction": "ROW2COL",
+    "features": {
+        "bootmagic": true,
+        "command": false,
+        "console": false,
+        "extrakey": true,
+        "mousekey": true,
+        "nkro": true
+    },
+    "matrix_pins": {
+        "cols": ["B10", "B1", "B0", "A7", "A6", "A5"],
+        "rows": ["A4", "A3", "A2", "A1", "A0"]
+    },
+    "development_board": "blackpill_f411",
+    "url": "",
+    "usb": {
+        "device_version": "1.0.0",
+        "vid": "0xFEED",
+        "pid": "0x2B2B"
+    },
+    "split": {
+        "enabled": true,
+        "transport": {
+            "sync_matrix_state": true
+        }
+    },
+    "community_layouts": ["ortho_5x12"],
+    "layouts": {
+        "LAYOUT_ortho_5x12": {
+            "layout": [
+                {"matrix": [0, 0], "x": 0, "y": 0},
+                {"matrix": [0, 1], "x": 1, "y": 0},
+                {"matrix": [0, 2], "x": 2, "y": 0},
+                {"matrix": [0, 3], "x": 3, "y": 0},
+                {"matrix": [0, 4], "x": 4, "y": 0},
+                {"matrix": [0, 5], "x": 5, "y": 0},
+
+                {"matrix": [5, 0], "x": 7, "y": 0},
+                {"matrix": [5, 1], "x": 8, "y": 0},
+                {"matrix": [5, 2], "x": 9, "y": 0},
+                {"matrix": [5, 3], "x": 10, "y": 0},
+                {"matrix": [5, 4], "x": 11, "y": 0},
+                {"matrix": [5, 5], "x": 12, "y": 0},
+
+                {"matrix": [1, 0], "x": 0, "y": 1},
+                {"matrix": [1, 1], "x": 1, "y": 1},
+                {"matrix": [1, 2], "x": 2, "y": 1},
+                {"matrix": [1, 3], "x": 3, "y": 1},
+                {"matrix": [1, 4], "x": 4, "y": 1},
+                {"matrix": [1, 5], "x": 5, "y": 1},
+
+                {"matrix": [6, 0], "x": 7, "y": 1},
+                {"matrix": [6, 1], "x": 8, "y": 1},
+                {"matrix": [6, 2], "x": 9, "y": 1},
+                {"matrix": [6, 3], "x": 10, "y": 1},
+                {"matrix": [6, 4], "x": 11, "y": 1},
+                {"matrix": [6, 5], "x": 12, "y": 1},
+
+                {"matrix": [2, 0], "x": 0, "y": 2},
+                {"matrix": [2, 1], "x": 1, "y": 2},
+                {"matrix": [2, 2], "x": 2, "y": 2},
+                {"matrix": [2, 3], "x": 3, "y": 2},
+                {"matrix": [2, 4], "x": 4, "y": 2},
+                {"matrix": [2, 5], "x": 5, "y": 2},
+
+                {"matrix": [7, 0], "x": 7, "y": 2},
+                {"matrix": [7, 1], "x": 8, "y": 2},
+                {"matrix": [7, 2], "x": 9, "y": 2},
+                {"matrix": [7, 3], "x": 10, "y": 2},
+                {"matrix": [7, 4], "x": 11, "y": 2},
+                {"matrix": [7, 5], "x": 12, "y": 2},
+
+                {"matrix": [3, 0], "x": 0, "y": 3},
+                {"matrix": [3, 1], "x": 1, "y": 3},
+                {"matrix": [3, 2], "x": 2, "y": 3},
+                {"matrix": [3, 3], "x": 3, "y": 3},
+                {"matrix": [3, 4], "x": 4, "y": 3},
+                {"matrix": [3, 5], "x": 5, "y": 3},
+
+                {"matrix": [8, 0], "x": 7, "y": 3},
+                {"matrix": [8, 1], "x": 8, "y": 3},
+                {"matrix": [8, 2], "x": 9, "y": 3},
+                {"matrix": [8, 3], "x": 10, "y": 3},
+                {"matrix": [8, 4], "x": 11, "y": 3},
+                {"matrix": [8, 5], "x": 12, "y": 3},
+
+                {"matrix": [4, 0], "x": 0, "y": 4},
+                {"matrix": [4, 1], "x": 1, "y": 4},
+                {"matrix": [4, 2], "x": 2, "y": 4},
+                {"matrix": [4, 3], "x": 3, "y": 4},
+                {"matrix": [4, 4], "x": 4, "y": 4},
+                {"matrix": [4, 5], "x": 5, "y": 4},
+
+                {"matrix": [9, 0], "x": 7, "y": 4},
+                {"matrix": [9, 1], "x": 8, "y": 4},
+                {"matrix": [9, 2], "x": 9, "y": 4},
+                {"matrix": [9, 3], "x": 10, "y": 4},
+                {"matrix": [9, 4], "x": 11, "y": 4},
+                {"matrix": [9, 5], "x": 12, "y": 4}
+            ]
+        }
+    }
+}
diff --git a/keyboards/handwired/riblee_split/keymaps/default/keymap.c b/keyboards/handwired/riblee_split/keymaps/default/keymap.c
new file mode 100644
index 0000000000..f954599c90
--- /dev/null
+++ b/keyboards/handwired/riblee_split/keymaps/default/keymap.c
@@ -0,0 +1,155 @@
+// Copyright 2023 Daniel Reibl (@riblee)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include QMK_KEYBOARD_H
+
+// Each layer gets a name for readability, which is then used in the keymap matrix below.
+// The underscores don't mean anything - you can have a layer called STUFF or any other name.
+// Layer names don't all need to be of the same length, obviously, and you can also skip them
+// entirely and just use numbers.
+enum layer_names {
+  _QWERTY,
+  _COLEMAK,
+  _DVORAK,
+  _LOWER,
+  _RAISE,
+  _ADJUST
+};
+
+enum custom_keycodes {
+  QWERTY = SAFE_RANGE,
+  COLEMAK,
+  DVORAK,
+  LOWER,
+  RAISE,
+  ADJUST,
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* Qwerty
+     * ,-----------------------------------------------------------------------------------.
+     * |   `  |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  | Bksp |
+     * |------+------+------+------+------+------+------+------+------+------+------+------|
+     * | Tab  |   Q  |   W  |   E  |   R  |   T  |   Y  |   U  |   I  |   O  |   P  | Del  |
+     * |------+------+------+------+------+-------------+------+------+------+------+------|
+     * | Esc  |   A  |   S  |   D  |   F  |   G  |   H  |   J  |   K  |   L  |   ;  |  "   |
+     * |------+------+------+------+------+------|------+------+------+------+------+------|
+     * | Shift|   Z  |   X  |   C  |   V  |   B  |   N  |   M  |   ,  |   .  |   /  |Enter |
+     * |------+------+------+------+------+------+------+------+------+------+------+------|
+     * |Adjust| Ctrl | Alt  | GUI  |Lower |Space |Space |Raise | Left | Down |  Up  |Right |
+     * `-----------------------------------------------------------------------------------'
+     */
+     [_QWERTY] = LAYOUT_ortho_5x12(
+       KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC,
+       KC_TAB,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_DEL,
+       KC_ESC,  KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_QUOT,
+       KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_ENT ,
+       ADJUST,  KC_LCTL, KC_LALT, KC_LGUI, LOWER,   KC_SPC,  KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT
+     ),
+
+     /* Colemak
+     * ,-----------------------------------------------------------------------------------.
+     * |   `  |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  | Bksp |
+     * |------+------+------+------+------+------+------+------+------+------+------+------|
+     * | Tab  |   Q  |   W  |   F  |   P  |   G  |   J  |   L  |   U  |   Y  |   ;  | Del  |
+     * |------+------+------+------+------+-------------+------+------+------+------+------|
+     * | Esc  |   A  |   R  |   S  |   T  |   D  |   H  |   N  |   E  |   I  |   O  |  "   |
+     * |------+------+------+------+------+------|------+------+------+------+------+------|
+     * | Shift|   Z  |   X  |   C  |   V  |   B  |   K  |   M  |   ,  |   .  |   /  |Enter |
+     * |------+------+------+------+------+------+------+------+------+------+------+------|
+     * |Adjust| Ctrl | Alt  | GUI  |Lower |Space |Space |Raise | Left | Down |  Up  |Right |
+     * `-----------------------------------------------------------------------------------'
+     */
+     [_COLEMAK] = LAYOUT_ortho_5x12(
+       KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC,
+       KC_TAB,  KC_Q,    KC_W,    KC_F,    KC_P,    KC_G,    KC_J,    KC_L,    KC_U,    KC_Y,    KC_SCLN, KC_DEL,
+       KC_ESC,  KC_A,    KC_R,    KC_S,    KC_T,    KC_D,    KC_H,    KC_N,    KC_E,    KC_I,    KC_O,    KC_QUOT,
+       KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_K,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_ENT ,
+       ADJUST,  KC_LCTL, KC_LALT, KC_LGUI, LOWER,   KC_SPC,  KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT
+     ),
+
+     /* Dvorak
+     * ,-----------------------------------------------------------------------------------.
+     * |   `  |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  | Bksp |
+     * |------+------+------+------+------+------+------+------+------+------+------+------|
+     * | Tab  |   "  |   ,  |   .  |   P  |   Y  |   F  |   G  |   C  |   R  |   L  | Del  |
+     * |------+------+------+------+------+-------------+------+------+------+------+------|
+     * | Esc  |   A  |   O  |   E  |   U  |   I  |   D  |   H  |   T  |   N  |   S  |  /   |
+     * |------+------+------+------+------+------|------+------+------+------+------+------|
+     * | Shift|   ;  |   Q  |   J  |   K  |   X  |   B  |   M  |   W  |   V  |   Z  |Enter |
+     * |------+------+------+------+------+------+------+------+------+------+------+------|
+     * |Adjust| Ctrl | Alt  | GUI  |Lower |Space |Space |Raise | Left | Down |  Up  |Right |
+     * `-----------------------------------------------------------------------------------'
+     */
+     [_DVORAK] = LAYOUT_ortho_5x12(
+       KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC,
+       KC_TAB,  KC_QUOT, KC_COMM, KC_DOT,  KC_P,    KC_Y,    KC_F,    KC_G,    KC_C,    KC_R,    KC_L,    KC_DEL,
+       KC_ESC,  KC_A,    KC_O,    KC_E,    KC_U,    KC_I,    KC_D,    KC_H,    KC_T,    KC_N,    KC_S,    KC_SLSH,
+       KC_LSFT, KC_SCLN, KC_Q,    KC_J,    KC_K,    KC_X,    KC_B,    KC_M,    KC_W,    KC_V,    KC_Z,    KC_ENT ,
+       ADJUST,  KC_LCTL, KC_LALT, KC_LGUI, LOWER,   KC_SPC,  KC_SPC,  RAISE,   KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT
+     ),
+
+     /* Lower
+     * ,-----------------------------------------------------------------------------------.
+     * |   ~  |   !  |   @  |   #  |   $  |   %  |   ^  |   &  |   *  |   (  |   )  | Bksp |
+     * |------+------+------+------+------+-------------+------+------+------+------+------|
+     * |   ~  |   !  |   @  |   #  |   $  |   %  |   ^  |   &  |   *  |   (  |   )  | Del  |
+     * |------+------+------+------+------+-------------+------+------+------+------+------|
+     * | Del  |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |   _  |   +  |     |    \  |  |   |
+     * |------+------+------+------+------+------|------+------+------+------+------+------|
+     * |      |  F7  |  F8  |  F9  |  F10 |  F11 |  F12 |ISO ~ |ISO | | Home | End  |      |
+     * |------+------+------+------+------+------+------+------+------+------+------+------|
+     * |      |      |      |      |      |             |      | Next | Vol- | Vol+ | Play |
+     * `-----------------------------------------------------------------------------------'
+     */
+     [_LOWER] = LAYOUT_ortho_5x12(
+       KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
+       KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL,
+       KC_DEL,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
+       BL_STEP, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,S(KC_NUHS),S(KC_NUBS),KC_HOME,KC_END, _______,
+       _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
+     ),
+ 
+     /* Raise
+     * ,-----------------------------------------------------------------------------------.
+     * |   `  |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  | Bksp |
+     * |------+------+------+------+------+-------------+------+------+------+------+------|
+     * |   `  |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  | Del  |
+     * |------+------+------+------+------+-------------+------+------+------+------+------|
+     * | Del  |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |   -  |   =  |   [  |   ]  |  \   |
+     * |------+------+------+------+------+------|------+------+------+------+------+------|
+     * |      |  F7  |  F8  |  F9  |  F10 |  F11 |  F12 |ISO # |ISO / |Pg Up |Pg Dn |      |
+     * |------+------+------+------+------+------+------+------+------+------+------+------|
+     * |      |      |      |      |      |             |      | Next | Vol- | Vol+ | Play |
+     * `-----------------------------------------------------------------------------------'
+     */
+     [_RAISE] = LAYOUT_ortho_5x12(
+       KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC,
+       KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_DEL,
+       KC_DEL,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_MINS, KC_EQL,  KC_LBRC, KC_RBRC, KC_BSLS,
+       _______, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_NUHS, KC_NUBS, KC_PGUP, KC_PGDN, _______,
+       _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
+     ),
+ 
+     /* Adjust (Lower + Raise)
+     * ,-----------------------------------------------------------------------------------.
+     * |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |  F7  |  F8  |  F9  |  F10 |  F11 |  F12 |
+     * |------+------+------+------+------+------+------+------+------+------+------+------|
+     * |      | Reset|RGB Tg|RGB Md|Hue Up|Hue Dn|Sat Up|Sat Dn|Val Up|Val Dn|      |  Del |
+     * |------+------+------+------+------+-------------+------+------+------+------+------|
+     * |      |      |      |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|      |      |
+     * |------+------+------+------+------+------|------+------+------+------+------+------|
+     * |      |      |      |      |      |      |      |      |      |      |      |      |
+     * |------+------+------+------+------+------+------+------+------+------+------+------|
+     * |      |      |      |      |      |             |      |      |      |      |      |
+     * `-----------------------------------------------------------------------------------'
+     */
+     [_ADJUST] =  LAYOUT_ortho_5x12(
+       KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,
+       _______, QK_BOOT, RGB_TOG, RGB_MOD, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, RGB_VAD, RGB_VAI, _______, KC_DEL,
+       _______, _______, _______, AU_ON,   AU_OFF,  AG_NORM, AG_SWAP, QWERTY,  COLEMAK, DVORAK,  _______, _______,
+       _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
+       _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
+     )
+
+};
diff --git a/keyboards/handwired/riblee_split/mcuconf.h b/keyboards/handwired/riblee_split/mcuconf.h
new file mode 100644
index 0000000000..4ea061c7bf
--- /dev/null
+++ b/keyboards/handwired/riblee_split/mcuconf.h
@@ -0,0 +1,7 @@
+// Copyright 2023 Daniel Reibl (@riblee)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include_next <mcuconf.h>
+
+#undef STM32_SERIAL_USE_USART1
+#define STM32_SERIAL_USE_USART1 TRUE
diff --git a/keyboards/handwired/riblee_split/readme.md b/keyboards/handwired/riblee_split/readme.md
new file mode 100644
index 0000000000..b0acf5b3ba
--- /dev/null
+++ b/keyboards/handwired/riblee_split/readme.md
@@ -0,0 +1,24 @@
+# Handwired Split
+
+This is a compact (12x5) ortholinear split keyboard.
+
+* Keyboard Maintainer: [Daniel Reibl](https://github.com/riblee)
+* Hardware Supported: STM32F411 BlackPill
+
+Make example for this keyboard (after setting up your build environment):
+
+    make handwired/riblee_split:default
+
+Flashing example for this keyboard:
+
+    make handwired/riblee_split:default:flash
+
+See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
+
+## Bootloader
+
+Enter the bootloader in 3 ways:
+
+* **Bootmagic reset**: Hold down the key at (0,0) in the matrix (usually the top left key or Escape) and plug in the keyboard
+* **Physical reset button**: Briefly press the button on the back of the PCB - some may have pads you must short instead
+* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available
diff --git a/keyboards/handwired/riblee_split/rules.mk b/keyboards/handwired/riblee_split/rules.mk
new file mode 100644
index 0000000000..c6e2988321
--- /dev/null
+++ b/keyboards/handwired/riblee_split/rules.mk
@@ -0,0 +1 @@
+SERIAL_DRIVER = usart