Browse Source

[Keyboard] Kobold r1 (#25161)

* Kobold r1

* Apply suggestions from code review

Co-authored-by: jack <jack@pngu.org>

* `board_init` => `early_hardware_init_post`.

---------

Co-authored-by: jack <jack@pngu.org>
Nick Brassel 1 year ago
parent
commit
e83b709169

+ 29 - 0
keyboards/tzarc/kobold/config.h

@@ -0,0 +1,29 @@
+// Copyright 2025 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+// Hardware-specific definitions
+#define RGB_ENABLE_PIN C11
+
+// WS2812 Configuration
+#define WS2812_PWM_DRIVER PWMD17
+#define WS2812_PWM_CHANNEL 1
+#define WS2812_PWM_PAL_MODE 10
+#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
+#define WS2812_PWM_DMA_CHANNEL 1
+#define WS2812_PWM_DMAMUX_ID STM32_DMAMUX1_TIM17_UP
+
+// SPI Configuration
+#define SPI_DRIVER SPID1
+#define SPI_SCK_PIN A5
+#define SPI_SCK_PAL_MODE 5
+#define SPI_MOSI_PIN A7
+#define SPI_MOSI_PAL_MODE 5
+#define SPI_MISO_PIN A6
+#define SPI_MISO_PAL_MODE 5
+
+// External NOR Flash config
+#define EXTERNAL_FLASH_SPI_MODE 0
+#define EXTERNAL_FLASH_SPI_SLAVE_SELECT_PIN B10
+#define EXTERNAL_FLASH_SPI_CLOCK_DIVISOR 4     // (160MHz/4) => 40MHz
+#define EXTERNAL_FLASH_SIZE (16 * 1024 * 1024) // 128Mb/16MB capacity

+ 8 - 0
keyboards/tzarc/kobold/halconf.h

@@ -0,0 +1,8 @@
+// Copyright 2025 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+
+#define HAL_USE_PWM TRUE
+#define HAL_USE_SPI TRUE
+
+#include_next <halconf.h>

+ 82 - 0
keyboards/tzarc/kobold/info.json

@@ -0,0 +1,82 @@
+{
+    "manufacturer": "Tzarc",
+    "keyboard_name": "Kobold",
+    "url": "https://github.com/tzarc/keyboards/tree/main/Kobold",
+    "maintainer": "tzarc",
+    "bootloader": "stm32-dfu",
+    "build": {
+        "lto": true
+    },
+    "dynamic_keymap": {
+        "layer_count": 32
+    },
+    "eeprom": {
+        "driver": "wear_leveling",
+        "wear_leveling": {
+            "backing_size": 32768,
+            "driver": "spi_flash"
+        }
+    },
+    "features": {
+        "bootmagic": true,
+        "rgb_matrix": true
+    },
+    "matrix_pins": {
+        "direct": [
+            ["B14", "C6", "B9", "B7", "B13", "B15", "C13", "C15", "B12", "B0", "A2", "A0", "B11", "A4", "A3", "A1"]
+        ]
+    },
+    "processor": "STM32G431",
+    "rgb_matrix": {
+        "driver": "ws2812",
+        "layout": [
+            {"x": 0, "y": 0, "flags": 2},
+            {"x": 75, "y": 0, "flags": 2},
+            {"x": 150, "y": 0, "flags": 2},
+            {"x": 224, "y": 0, "flags": 2},
+            {"x": 224, "y": 21, "flags": 2},
+            {"x": 150, "y": 21, "flags": 2},
+            {"x": 75, "y": 21, "flags": 2},
+            {"x": 0, "y": 21, "flags": 2},
+            {"x": 0, "y": 43, "flags": 2},
+            {"x": 75, "y": 43, "flags": 2},
+            {"x": 150, "y": 43, "flags": 2},
+            {"x": 224, "y": 43, "flags": 2},
+            {"x": 224, "y": 64, "flags": 2},
+            {"x": 150, "y": 64, "flags": 2},
+            {"x": 75, "y": 64, "flags": 2},
+            {"x": 0, "y": 64, "flags": 2}
+        ]
+    },
+    "usb": {
+        "pid": "0x4921",
+        "vid": "0x1209"
+    },
+    "ws2812": {
+        "driver": "pwm",
+        "pin": "B5"
+    },
+    "community_layouts": ["ortho_4x4"],
+    "layouts": {
+        "LAYOUT_ortho_4x4": {
+            "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": 0, "y": 1},
+                {"matrix": [0, 5], "x": 1, "y": 1},
+                {"matrix": [0, 6], "x": 2, "y": 1},
+                {"matrix": [0, 7], "x": 3, "y": 1},
+                {"matrix": [0, 8], "x": 0, "y": 2},
+                {"matrix": [0, 9], "x": 1, "y": 2},
+                {"matrix": [0, 10], "x": 2, "y": 2},
+                {"matrix": [0, 11], "x": 3, "y": 2},
+                {"matrix": [0, 12], "x": 0, "y": 3},
+                {"matrix": [0, 13], "x": 1, "y": 3},
+                {"matrix": [0, 14], "x": 2, "y": 3},
+                {"matrix": [0, 15], "x": 3, "y": 3}
+            ]
+        }
+    }
+}

+ 14 - 0
keyboards/tzarc/kobold/keymaps/default/keymap.c

@@ -0,0 +1,14 @@
+// Copyright 2025 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include QMK_KEYBOARD_H
+
+// clang-format off
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [0] = LAYOUT_ortho_4x4(
+        KC_A, KC_B, KC_C, KC_D,
+        KC_E, KC_F, KC_G, KC_H,
+        KC_I, KC_J, KC_K, KC_L,
+        KC_M, KC_N, KC_O, KC_P
+    ),
+};
+// clang-format on

+ 18 - 0
keyboards/tzarc/kobold/kobold.c

@@ -0,0 +1,18 @@
+// Copyright 2025 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include QMK_KEYBOARD_H
+
+void early_hardware_init_post(void) {
+    // Disable RGB LEDs
+    gpio_set_pin_output(RGB_ENABLE_PIN);
+    gpio_write_pin(RGB_ENABLE_PIN, 1);
+}
+
+void housekeeping_task_kb() {
+    // Enable RGB LEDs after 200 milliseconds
+    static bool rgb_enabled = false;
+    if (!rgb_enabled && timer_read32() > 200) {
+        gpio_write_pin(RGB_ENABLE_PIN, 0);
+        rgb_enabled = true;
+    }
+}

+ 12 - 0
keyboards/tzarc/kobold/mcuconf.h

@@ -0,0 +1,12 @@
+// Copyright 2025 Nick Brassel (@tzarc)
+// SPDX-License-Identifier: GPL-2.0-or-later
+#pragma once
+#include_next <mcuconf.h>
+
+// Used for SK6812 chain
+#undef STM32_PWM_USE_TIM17
+#define STM32_PWM_USE_TIM17 TRUE
+
+// Used for NOR Flash
+#undef STM32_SPI_USE_SPI1
+#define STM32_SPI_USE_SPI1 TRUE

+ 5 - 0
keyboards/tzarc/kobold/r1/keyboard.json

@@ -0,0 +1,5 @@
+{
+    "usb": {
+        "device_version": "1.0.0"
+    }
+}

+ 29 - 0
keyboards/tzarc/kobold/readme.md

@@ -0,0 +1,29 @@
+# Kobold
+
+![Kobold](https://i.imgur.com/R8nDodO.jpg)
+
+4x4 macropad running QMK, in the same form factor as a bm16s. Non-standard Choc key spacing.
+
+North-facing RGB, SPI NOR Flash, voltage and current measurement, direct pin matrix, reset to bootloader by holding top 4 keys.
+
+* Keyboard Maintainer: [tzarc](https://github.com/tzarc)
+* Hardware Supported: Kobold, r1
+* Hardware Availability: [KiCad files](https://github.com/tzarc/keyboards/tree/main/Kobold)
+
+Make example for this keyboard (after setting up your build environment):
+
+    make tzarc/kobold/r1:default
+
+Flashing example for this keyboard:
+
+    make tzarc/kobold/r1: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 top left key and plug in the keyboard
+* **Physical reset button**: Simultaneously press the top four keys, or press the physical button on the back marked 'D'.
+* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available