From 3072feb8ed79c861a0066ec6721669dec6f6309f Mon Sep 17 00:00:00 2001
From: Steven Karrmann <skarrmann@gmail.com>
Date: Sat, 24 Sep 2022 11:35:37 -0400
Subject: [PATCH] [Keyboard] Add Janus keyboard (#18367)

Co-authored-by: Ryan <fauxpark@gmail.com>
---
 keyboards/janus/config.h                  | 16 +++++
 keyboards/janus/halconf.h                 |  9 +++
 keyboards/janus/info.json                 | 75 +++++++++++++++++++++++
 keyboards/janus/keymaps/default/keymap.c  | 50 +++++++++++++++
 keyboards/janus/keymaps/default/readme.md | 13 ++++
 keyboards/janus/mcuconf.h                 |  9 +++
 keyboards/janus/readme.md                 | 27 ++++++++
 keyboards/janus/rules.mk                  |  1 +
 8 files changed, 200 insertions(+)
 create mode 100644 keyboards/janus/config.h
 create mode 100644 keyboards/janus/halconf.h
 create mode 100644 keyboards/janus/info.json
 create mode 100644 keyboards/janus/keymaps/default/keymap.c
 create mode 100644 keyboards/janus/keymaps/default/readme.md
 create mode 100644 keyboards/janus/mcuconf.h
 create mode 100644 keyboards/janus/readme.md
 create mode 100644 keyboards/janus/rules.mk

diff --git a/keyboards/janus/config.h b/keyboards/janus/config.h
new file mode 100644
index 0000000000..8124f0db57
--- /dev/null
+++ b/keyboards/janus/config.h
@@ -0,0 +1,16 @@
+// Copyright 2022 Steven Karrmann (@skarrmann)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "config_common.h"
+
+/* Serial communication */
+#define SERIAL_USART_FULL_DUPLEX
+#define SERIAL_USART_TX_PIN GP0
+#define SERIAL_USART_RX_PIN GP1
+
+/* Double tap reset button to enter bootloader */
+#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET
+#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_LED GP17
+#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 500U
\ No newline at end of file
diff --git a/keyboards/janus/halconf.h b/keyboards/janus/halconf.h
new file mode 100644
index 0000000000..550a6e0abf
--- /dev/null
+++ b/keyboards/janus/halconf.h
@@ -0,0 +1,9 @@
+// Copyright 2022 Steven Karrmann (@skarrmann)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include_next <halconf.h>
+
+#undef HAL_USE_SIO
+#define HAL_USE_SIO TRUE
\ No newline at end of file
diff --git a/keyboards/janus/info.json b/keyboards/janus/info.json
new file mode 100644
index 0000000000..6169dc6ed5
--- /dev/null
+++ b/keyboards/janus/info.json
@@ -0,0 +1,75 @@
+{
+    "keyboard_name": "Janus",
+    "manufacturer": "Steven Karrmann",
+    "url": "https://github.com/skarrmann/janus",
+    "maintainer": "skarrmann",
+    "processor": "RP2040",
+    "bootloader": "rp2040",
+    "diode_direction": "COL2ROW",
+    "matrix_pins": {
+        "cols": ["GP6", "GP7", "GP2", "GP4", "GP3"],
+        "rows": ["GP26", "GP27", "GP28", "GP29"]
+    },
+    "indicators": {
+        "num_lock": "GP17",
+        "caps_lock": "GP16",
+        "scroll_lock": "GP25",
+        "on_state": 0
+    },
+    "features": {
+        "bootmagic": true,
+        "command": false,
+        "console": false,
+        "extrakey": true,
+        "mousekey": true,
+        "nkro": true
+    },
+    "split": {
+        "enabled": true
+    },
+    "layouts": {
+        "LAYOUT_split_3x5_2": {
+            "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": [4, 4], "x": 6, "y": 0 },
+                { "matrix": [4, 3], "x": 7, "y": 0 },
+                { "matrix": [4, 2], "x": 8, "y": 0 },
+                { "matrix": [4, 1], "x": 9, "y": 0 },
+                { "matrix": [4, 0], "x": 10, "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": [5, 4], "x": 6, "y": 1 },
+                { "matrix": [5, 3], "x": 7, "y": 1 },
+                { "matrix": [5, 2], "x": 8, "y": 1 },
+                { "matrix": [5, 1], "x": 9, "y": 1 },
+                { "matrix": [5, 0], "x": 10, "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": [6, 4], "x": 6, "y": 2 },
+                { "matrix": [6, 3], "x": 7, "y": 2 },
+                { "matrix": [6, 2], "x": 8, "y": 2 },
+                { "matrix": [6, 1], "x": 9, "y": 2 },
+                { "matrix": [6, 0], "x": 10, "y": 2 },
+                { "matrix": [3, 3], "x": 3, "y": 3 },
+                { "matrix": [3, 4], "x": 4, "y": 3 },
+                { "matrix": [7, 4], "x": 6, "y": 3 },
+                { "matrix": [7, 3], "x": 7, "y": 3 }
+            ]
+        }
+    },
+    "usb": {
+        "device_version": "1.0.0",
+        "pid": "0x9A25",
+        "vid": "0xFEED"
+    }
+}
\ No newline at end of file
diff --git a/keyboards/janus/keymaps/default/keymap.c b/keyboards/janus/keymaps/default/keymap.c
new file mode 100644
index 0000000000..440645a15d
--- /dev/null
+++ b/keyboards/janus/keymaps/default/keymap.c
@@ -0,0 +1,50 @@
+// Copyright 2022 Steven Karrmann (@skarrmann)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include QMK_KEYBOARD_H
+
+enum layer_names {
+    _BASE,
+    _SYMBOL,
+    _NAVIGATION,
+    _FUNCTION
+};
+
+#define MO_SYM MO(_SYMBOL)
+#define MO_NAV MO(_NAVIGATION)
+#define MO_FUN MO(_FUNCTION)
+#define OS_LCTL OSM(MOD_LCTL)
+#define OS_LSFT OSM(MOD_LSFT)
+#define OS_LALT OSM(MOD_LALT)
+#define OS_LGUI OSM(MOD_LGUI)
+#define OS_RCTL OSM(MOD_RCTL)
+#define OS_RSFT OSM(MOD_RSFT)
+#define OS_RALT OSM(MOD_RALT)
+#define OS_RGUI OSM(MOD_RGUI)
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [_BASE] = LAYOUT_split_3x5_2(
+        KC_Q   , KC_W   , KC_E   , KC_R   , KC_T   , KC_Y   , KC_U   , KC_I   , KC_O   , KC_P   ,
+        KC_A   , KC_S   , KC_D   , KC_F   , KC_G   , KC_H   , KC_J   , KC_K   , KC_L   , KC_QUOT,
+        KC_Z   , KC_X   , KC_C   , KC_V   , KC_B   , KC_N   , KC_M   , KC_COMM, KC_DOT , KC_SLSH,
+                                   MO_NAV , KC_LSFT, KC_SPC , MO_SYM
+    ),
+    [_SYMBOL] = LAYOUT_split_3x5_2(
+        KC_SCLN, KC_LBRC, KC_RBRC, KC_5   , XXXXXXX, XXXXXXX, KC_6   , KC_MINS, KC_EQL , KC_GRV ,
+        KC_1   , KC_2   , KC_3   , KC_4   , KC_BSLS, XXXXXXX, KC_7   , KC_8   , KC_9   , KC_0   ,
+        OS_LGUI, OS_LALT, OS_LSFT, OS_LCTL, XXXXXXX, XXXXXXX, OS_RCTL, OS_RSFT, OS_RALT, OS_RGUI,
+                                   MO_FUN , _______, _______, _______
+    ),
+    [_NAVIGATION] = LAYOUT_split_3x5_2(
+        KC_PSCR, KC_INS , KC_APP , KC_DEL , XXXXXXX, XXXXXXX, KC_HOME, KC_PGDN, KC_PGUP, KC_END ,
+        KC_ESC , KC_TAB , KC_ENT , KC_BSPC, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP  , KC_RGHT,
+        OS_LGUI, OS_LALT, OS_LSFT, OS_LCTL, XXXXXXX, XXXXXXX, OS_RCTL, OS_RSFT, OS_RALT, OS_RGUI,
+                                   _______, _______, _______, MO_FUN
+    ),
+    [_FUNCTION] = LAYOUT_split_3x5_2(
+        KC_F1  , KC_F2  , KC_F3  , KC_F4  , QK_BOOT, KC_SLCK, KC_F9  , KC_F10 , KC_F11 , KC_F12 ,
+        KC_F5  , KC_F6  , KC_F7  , KC_F8  , XXXXXXX, KC_CLCK, KC_MUTE, KC_VOLD, KC_VOLU, KC_PAUS,
+        OS_LGUI, OS_LALT, OS_LSFT, OS_LCTL, XXXXXXX, KC_NLCK, OS_RCTL, OS_RSFT, OS_RALT, OS_RGUI,
+                                   _______, _______, _______, _______
+    ),
+};
\ No newline at end of file
diff --git a/keyboards/janus/keymaps/default/readme.md b/keyboards/janus/keymaps/default/readme.md
new file mode 100644
index 0000000000..dc7534e317
--- /dev/null
+++ b/keyboards/janus/keymaps/default/readme.md
@@ -0,0 +1,13 @@
+# Janus Default Keymap
+
+![Janus default keymap image](https://i.imgur.com/7FevUIZh.png)
+
+The default Janus keymap is simple and organized. The only QMK special features used are layers and one shot keys for modifiers.
+
+It is inspired by [Callum's keymap](https://github.com/qmk/qmk_firmware/tree/master/users/callum), with a few differences:
+
+* Modifier keys are moved to the bottom row on every layer, and are mirrored on both sides.
+* Symbol layer only contains non-shifted symbol keys.
+* General differences in key positions.
+
+For simplicity's sake, the keymap uses QMK's native one shot key implementation. There are other excellent one shot implementations out there, including Callum's in the aforementioned keymap.
\ No newline at end of file
diff --git a/keyboards/janus/mcuconf.h b/keyboards/janus/mcuconf.h
new file mode 100644
index 0000000000..c41253d4fb
--- /dev/null
+++ b/keyboards/janus/mcuconf.h
@@ -0,0 +1,9 @@
+// Copyright 2022 Steven Karrmann (@skarrmann)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include_next <mcuconf.h>
+
+#undef RP_SIO_USE_UART0
+#define RP_SIO_USE_UART0 TRUE
\ No newline at end of file
diff --git a/keyboards/janus/readme.md b/keyboards/janus/readme.md
new file mode 100644
index 0000000000..aa9e65cdc4
--- /dev/null
+++ b/keyboards/janus/readme.md
@@ -0,0 +1,27 @@
+# Janus
+
+![Janus](https://i.imgur.com/7Lzhafeh.jpg)
+
+A 34-key split ortholinear keyboard, powered by two Seeed XIAO RP2040.
+
+* Keyboard Maintainer: [Steven Karrmann](https://github.com/skarrmann)
+* Hardware Supported: Janus PCBs, Seeed XIAO RP2040
+* Hardware Availability: [Janus GitHub repository](https://github.com/skarrmann/janus)
+
+Make example for this keyboard (after setting up your build environment):
+
+    make janus:default
+
+Flashing example for this keyboard:
+
+    make janus: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 on the left half, or top right key on the right half, and then plug in the USB cable on that keyboard half.
+* **Physical reset button**: Double tap the reset button on the XIAO RP2040.
+* **Keycode in layout**: Press the key mapped to `QK_BOOT` if it is available.
diff --git a/keyboards/janus/rules.mk b/keyboards/janus/rules.mk
new file mode 100644
index 0000000000..59b74ac86b
--- /dev/null
+++ b/keyboards/janus/rules.mk
@@ -0,0 +1 @@
+SERIAL_DRIVER = usart
\ No newline at end of file