From a1b16b8227fbf43e67c398f926a922d4241a9829 Mon Sep 17 00:00:00 2001
From: Chad Skeeters <chad.skeeters@gmail.com>
Date: Wed, 20 Mar 2024 23:54:02 -0500
Subject: [PATCH] Support for slice65 from PizzaKeyboards (#23148)

---
 keyboards/pizzakeyboards/slice65/board.h      |  20 ++++
 keyboards/pizzakeyboards/slice65/info.json    | 105 ++++++++++++++++++
 .../slice65/keymaps/default/keymap.c          |  26 +++++
 .../slice65/keymaps/via/keymap.c              |  26 +++++
 .../slice65/keymaps/via/rules.mk              |   2 +
 .../pizzakeyboards/slice65/ld/STM32F303xB.ld  |  86 ++++++++++++++
 keyboards/pizzakeyboards/slice65/mcuconf.h    |  22 ++++
 keyboards/pizzakeyboards/slice65/readme.md    |  27 +++++
 keyboards/pizzakeyboards/slice65/rules.mk     |   1 +
 9 files changed, 315 insertions(+)
 create mode 100644 keyboards/pizzakeyboards/slice65/board.h
 create mode 100644 keyboards/pizzakeyboards/slice65/info.json
 create mode 100644 keyboards/pizzakeyboards/slice65/keymaps/default/keymap.c
 create mode 100644 keyboards/pizzakeyboards/slice65/keymaps/via/keymap.c
 create mode 100644 keyboards/pizzakeyboards/slice65/keymaps/via/rules.mk
 create mode 100644 keyboards/pizzakeyboards/slice65/ld/STM32F303xB.ld
 create mode 100644 keyboards/pizzakeyboards/slice65/mcuconf.h
 create mode 100644 keyboards/pizzakeyboards/slice65/readme.md
 create mode 100644 keyboards/pizzakeyboards/slice65/rules.mk

diff --git a/keyboards/pizzakeyboards/slice65/board.h b/keyboards/pizzakeyboards/slice65/board.h
new file mode 100644
index 0000000000..ba17e3b15e
--- /dev/null
+++ b/keyboards/pizzakeyboards/slice65/board.h
@@ -0,0 +1,20 @@
+/*
+Copyright 2022 Christoph Baumann
+
+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 STM32_HSECLK 16000000
+#include_next <board.h>
diff --git a/keyboards/pizzakeyboards/slice65/info.json b/keyboards/pizzakeyboards/slice65/info.json
new file mode 100644
index 0000000000..a6ae5a169f
--- /dev/null
+++ b/keyboards/pizzakeyboards/slice65/info.json
@@ -0,0 +1,105 @@
+{
+    "manufacturer": "Pizzakeyboards",
+    "keyboard_name": "Slice65",
+    "maintainer": "mm0nte",
+    "bootloader": "stm32-dfu",
+    "debounce": 10,
+    "diode_direction": "COL2ROW",
+    "features": {
+        "bootmagic": true,
+        "extrakey": true,
+        "mousekey": true,
+        "nkro": true
+    },
+    "matrix_pins": {
+        "cols": ["C14", "C13", "C15", "B6", "B5", "B4", "C4", "A7"],
+        "rows": ["C11", "C12", "B3", "D2", "A1", "A2", "A5", "A4", "B1", "B0"]
+    },
+    "processor": "STM32F303",
+    "qmk": {
+        "locking": {
+            "enabled": true,
+            "resync": true
+        }
+    },
+    "url": "www.keyboards.pizza",
+    "usb": {
+        "device_version": "1.0.0",
+        "pid": "0x707C",
+        "vid": "0x504B"
+    },
+    "community_layouts": ["65_ansi_blocker"],
+    "layouts": {
+        "LAYOUT_65_ansi_blocker": {
+            "layout": [
+                {"label": "ESC", "matrix": [0, 0], "x": 0, "y": 0},
+                {"label": "1", "matrix": [1, 0], "x": 1, "y": 0},
+                {"label": "2", "matrix": [0, 1], "x": 2, "y": 0},
+                {"label": "3", "matrix": [1, 1], "x": 3, "y": 0},
+                {"label": "4", "matrix": [0, 2], "x": 4, "y": 0},
+                {"label": "5", "matrix": [1, 2], "x": 5, "y": 0},
+                {"label": "6", "matrix": [0, 3], "x": 6, "y": 0},
+                {"label": "7", "matrix": [1, 3], "x": 7, "y": 0},
+                {"label": "8", "matrix": [0, 4], "x": 8, "y": 0},
+                {"label": "9", "matrix": [1, 4], "x": 9, "y": 0},
+                {"label": "0", "matrix": [0, 5], "x": 10, "y": 0},
+                {"label": "-", "matrix": [1, 5], "x": 11, "y": 0},
+                {"label": "=", "matrix": [0, 6], "x": 12, "y": 0},
+                {"label": "Backspace", "matrix": [1, 6], "x": 13, "y": 0, "w": 2},
+                {"label": "Home", "matrix": [0, 7], "x": 15, "y": 0},
+                {"label": "Tab", "matrix": [2, 0], "x": 0, "y": 1, "w": 1.5},
+                {"label": "Q", "matrix": [3, 0], "x": 1.5, "y": 1},
+                {"label": "W", "matrix": [2, 1], "x": 2.5, "y": 1},
+                {"label": "E", "matrix": [3, 1], "x": 3.5, "y": 1},
+                {"label": "R", "matrix": [2, 2], "x": 4.5, "y": 1},
+                {"label": "T", "matrix": [3, 2], "x": 5.5, "y": 1},
+                {"label": "Y", "matrix": [2, 3], "x": 6.5, "y": 1},
+                {"label": "U", "matrix": [3, 3], "x": 7.5, "y": 1},
+                {"label": "I", "matrix": [2, 4], "x": 8.5, "y": 1},
+                {"label": "O", "matrix": [3, 4], "x": 9.5, "y": 1},
+                {"label": "P", "matrix": [2, 5], "x": 10.5, "y": 1},
+                {"label": "[", "matrix": [3, 5], "x": 11.5, "y": 1},
+                {"label": "]", "matrix": [2, 6], "x": 12.5, "y": 1},
+                {"label": "\\", "matrix": [3, 6], "x": 13.5, "y": 1, "w": 1.5},
+                {"label": "End", "matrix": [2, 7], "x": 15, "y": 1},
+                {"label": "Capslock", "matrix": [4, 0], "x": 0, "y": 2, "w": 1.75},
+                {"label": "A", "matrix": [5, 0], "x": 1.75, "y": 2},
+                {"label": "S", "matrix": [4, 1], "x": 2.75, "y": 2},
+                {"label": "D", "matrix": [5, 1], "x": 3.75, "y": 2},
+                {"label": "F", "matrix": [4, 2], "x": 4.75, "y": 2},
+                {"label": "G", "matrix": [5, 2], "x": 5.75, "y": 2},
+                {"label": "H", "matrix": [4, 3], "x": 6.75, "y": 2},
+                {"label": "J", "matrix": [5, 3], "x": 7.75, "y": 2},
+                {"label": "K", "matrix": [4, 4], "x": 8.75, "y": 2},
+                {"label": "L", "matrix": [5, 4], "x": 9.75, "y": 2},
+                {"label": ";", "matrix": [4, 5], "x": 10.75, "y": 2},
+                {"label": "'", "matrix": [5, 5], "x": 11.75, "y": 2},
+                {"label": "Enter", "matrix": [5, 6], "x": 12.75, "y": 2, "w": 2.25},
+                {"label": "PgUp", "matrix": [4, 7], "x": 15, "y": 2},
+                {"label": "Shift", "matrix": [6, 0], "x": 0, "y": 3, "w": 2.25},
+                {"label": "Z", "matrix": [6, 1], "x": 2.25, "y": 3},
+                {"label": "X", "matrix": [7, 1], "x": 3.25, "y": 3},
+                {"label": "C", "matrix": [6, 2], "x": 4.25, "y": 3},
+                {"label": "V", "matrix": [7, 2], "x": 5.25, "y": 3},
+                {"label": "B", "matrix": [6, 3], "x": 6.25, "y": 3},
+                {"label": "N", "matrix": [7, 3], "x": 7.25, "y": 3},
+                {"label": "M", "matrix": [6, 4], "x": 8.25, "y": 3},
+                {"label": ",", "matrix": [7, 4], "x": 9.25, "y": 3},
+                {"label": ".", "matrix": [6, 5], "x": 10.25, "y": 3},
+                {"label": "/", "matrix": [7, 5], "x": 11.25, "y": 3},
+                {"label": "Shift", "matrix": [6, 6], "x": 12.25, "y": 3, "w": 1.75},
+                {"label": "Up", "matrix": [7, 6], "x": 14, "y": 3},
+                {"label": "PgDn", "matrix": [6, 7], "x": 15, "y": 3},
+                {"label": "Ctrl", "matrix": [8, 0], "x": 0, "y": 4, "w": 1.25},
+                {"label": "Win", "matrix": [9, 0], "x": 1.25, "y": 4, "w": 1.25},
+                {"label": "Alt", "matrix": [8, 1], "x": 2.5, "y": 4, "w": 1.25},
+                {"label": "Space", "matrix": [8, 3], "x": 3.75, "y": 4, "w": 6.25},
+                {"label": "Alt", "matrix": [8, 5], "x": 10, "y": 4, "w": 1.25},
+                {"label": "Ctrl", "matrix": [9, 5], "x": 11.25, "y": 4, "w": 1.25},
+                {"label": "Left", "matrix": [8, 6], "x": 13, "y": 4},
+                {"label": "Down", "matrix": [9, 6], "x": 14, "y": 4},
+                {"label": "Right", "matrix": [8, 7], "x": 15, "y": 4}
+            ]
+        }
+    }
+}
diff --git a/keyboards/pizzakeyboards/slice65/keymaps/default/keymap.c b/keyboards/pizzakeyboards/slice65/keymaps/default/keymap.c
new file mode 100644
index 0000000000..ed1ea2f0c6
--- /dev/null
+++ b/keyboards/pizzakeyboards/slice65/keymaps/default/keymap.c
@@ -0,0 +1,26 @@
+/* Copyright 2021 Christoph Baumann
+ *
+ * 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/>.
+ */
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [0] = LAYOUT_65_ansi_blocker(
+        KC_ESC,  KC_1,    KC_2,    KC_3, KC_4, KC_5, KC_6,   KC_7, KC_8, KC_9,    KC_0,    KC_MINS, KC_EQL,  KC_BSPC, KC_HOME,
+        KC_TAB,  KC_Q,    KC_W,    KC_E, KC_R, KC_T, KC_Y,   KC_U, KC_I, KC_O,    KC_P,    KC_LBRC, KC_RBRC, KC_BSLS, KC_END,
+        KC_CAPS, KC_A,    KC_S,    KC_D, KC_F, KC_G, KC_H,   KC_J, KC_K, KC_L,    KC_SCLN, KC_QUOT,          KC_ENT,  KC_PGUP,
+        KC_LSFT,          KC_Z,    KC_X, KC_C, KC_V, KC_B,   KC_N, KC_M, KC_COMM, KC_DOT,  KC_SLSH, KC_RSFT, KC_UP,   KC_PGDN,
+        KC_LCTL, KC_LWIN, KC_LALT,                   KC_SPC,                      KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT
+    ),
+};
diff --git a/keyboards/pizzakeyboards/slice65/keymaps/via/keymap.c b/keyboards/pizzakeyboards/slice65/keymaps/via/keymap.c
new file mode 100644
index 0000000000..904340ceec
--- /dev/null
+++ b/keyboards/pizzakeyboards/slice65/keymaps/via/keymap.c
@@ -0,0 +1,26 @@
+/* Copyright 2022 Christoph Baumann
+ *
+ * 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/>.
+ */
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [0] = LAYOUT_65_ansi_blocker(
+        KC_ESC,  KC_1,    KC_2,    KC_3, KC_4, KC_5, KC_6,   KC_7, KC_8, KC_9,    KC_0,    KC_MINS, KC_EQL,  KC_BSPC, KC_HOME,
+        KC_TAB,  KC_Q,    KC_W,    KC_E, KC_R, KC_T, KC_Y,   KC_U, KC_I, KC_O,    KC_P,    KC_LBRC, KC_RBRC, KC_BSLS, KC_END,
+        KC_CAPS, KC_A,    KC_S,    KC_D, KC_F, KC_G, KC_H,   KC_J, KC_K, KC_L,    KC_SCLN, KC_QUOT,          KC_ENT,  KC_PGUP,
+        KC_LSFT,          KC_Z,    KC_X, KC_C, KC_V, KC_B,   KC_N, KC_M, KC_COMM, KC_DOT,  KC_SLSH, KC_RSFT, KC_UP,   KC_PGDN,
+        KC_LCTL, KC_LWIN, KC_LALT,                   KC_SPC,                      KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT
+    )
+};
diff --git a/keyboards/pizzakeyboards/slice65/keymaps/via/rules.mk b/keyboards/pizzakeyboards/slice65/keymaps/via/rules.mk
new file mode 100644
index 0000000000..36b7ba9cbc
--- /dev/null
+++ b/keyboards/pizzakeyboards/slice65/keymaps/via/rules.mk
@@ -0,0 +1,2 @@
+VIA_ENABLE = yes
+LTO_ENABLE = yes
diff --git a/keyboards/pizzakeyboards/slice65/ld/STM32F303xB.ld b/keyboards/pizzakeyboards/slice65/ld/STM32F303xB.ld
new file mode 100644
index 0000000000..8ad8b0911c
--- /dev/null
+++ b/keyboards/pizzakeyboards/slice65/ld/STM32F303xB.ld
@@ -0,0 +1,86 @@
+/*
+    ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
+              Copyright (C) 2022       Christoph Baumann
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+*/
+
+/*
+ * STM32F303xC memory setup.
+ */
+MEMORY
+{
+    flash0 (rx) : org = 0x08000000, len = 128k
+    flash1 (rx) : org = 0x00000000, len = 0
+    flash2 (rx) : org = 0x00000000, len = 0
+    flash3 (rx) : org = 0x00000000, len = 0
+    flash4 (rx) : org = 0x00000000, len = 0
+    flash5 (rx) : org = 0x00000000, len = 0
+    flash6 (rx) : org = 0x00000000, len = 0
+    flash7 (rx) : org = 0x00000000, len = 0
+    ram0   (wx) : org = 0x20000000, len = 32k
+    ram1   (wx) : org = 0x00000000, len = 0
+    ram2   (wx) : org = 0x00000000, len = 0
+    ram3   (wx) : org = 0x00000000, len = 0
+    ram4   (wx) : org = 0x10000000, len = 8k
+    ram5   (wx) : org = 0x00000000, len = 0
+    ram6   (wx) : org = 0x00000000, len = 0
+    ram7   (wx) : org = 0x00000000, len = 0
+}
+
+/* For each data/text section two region are defined, a virtual region
+   and a load region (_LMA suffix).*/
+
+/* Flash region to be used for exception vectors.*/
+REGION_ALIAS("VECTORS_FLASH", flash0);
+REGION_ALIAS("VECTORS_FLASH_LMA", flash0);
+
+/* Flash region to be used for constructors and destructors.*/
+REGION_ALIAS("XTORS_FLASH", flash0);
+REGION_ALIAS("XTORS_FLASH_LMA", flash0);
+
+/* Flash region to be used for code text.*/
+REGION_ALIAS("TEXT_FLASH", flash0);
+REGION_ALIAS("TEXT_FLASH_LMA", flash0);
+
+/* Flash region to be used for read only data.*/
+REGION_ALIAS("RODATA_FLASH", flash0);
+REGION_ALIAS("RODATA_FLASH_LMA", flash0);
+
+/* Flash region to be used for various.*/
+REGION_ALIAS("VARIOUS_FLASH", flash0);
+REGION_ALIAS("VARIOUS_FLASH_LMA", flash0);
+
+/* Flash region to be used for RAM(n) initialization data.*/
+REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0);
+
+/* RAM region to be used for Main stack. This stack accommodates the processing
+   of all exceptions and interrupts.*/
+REGION_ALIAS("MAIN_STACK_RAM", ram0);
+
+/* RAM region to be used for the process stack. This is the stack used by
+   the main() function.*/
+REGION_ALIAS("PROCESS_STACK_RAM", ram0);
+
+/* RAM region to be used for data segment.*/
+REGION_ALIAS("DATA_RAM", ram0);
+REGION_ALIAS("DATA_RAM_LMA", flash0);
+
+/* RAM region to be used for BSS segment.*/
+REGION_ALIAS("BSS_RAM", ram0);
+
+/* RAM region to be used for the default heap.*/
+REGION_ALIAS("HEAP_RAM", ram0);
+
+/* Generic rules inclusion.*/
+INCLUDE rules.ld
diff --git a/keyboards/pizzakeyboards/slice65/mcuconf.h b/keyboards/pizzakeyboards/slice65/mcuconf.h
new file mode 100644
index 0000000000..aa059c9170
--- /dev/null
+++ b/keyboards/pizzakeyboards/slice65/mcuconf.h
@@ -0,0 +1,22 @@
+/*
+Copyright 2022 Christoph Baumann
+
+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
+
+#include_next <mcuconf.h>
+
+#undef STM32_PREDIV_VALUE
+#define STM32_PREDIV_VALUE 2
diff --git a/keyboards/pizzakeyboards/slice65/readme.md b/keyboards/pizzakeyboards/slice65/readme.md
new file mode 100644
index 0000000000..591f51b49e
--- /dev/null
+++ b/keyboards/pizzakeyboards/slice65/readme.md
@@ -0,0 +1,27 @@
+# Pizza Keyboards (V2) Slice65
+
+![Pizza V2](https://i.imgur.com/RfqnpVlh.jpeg)
+
+A 65% keyboard kit made and sold by [pizza keyboards](https://keyboards.pizza).
+
+* Keyboard Maintainer: [mm0nte](https://github.com/mm0nte)
+* Hardware Supported: Pizza V2 Slice65 (Hotswap) PCB
+* Hardware Availability: [Pizza Keyboards Store](https://keyboards.pizza/collections/store)
+
+Make example for this keyboard (after setting up your build environment):
+
+    make pizzakeyboards/slice65:default
+
+Flashing example for this keyboard:
+
+    make pizzakeyboards/slice65: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/pizzakeyboards/slice65/rules.mk b/keyboards/pizzakeyboards/slice65/rules.mk
new file mode 100644
index 0000000000..a36398ce43
--- /dev/null
+++ b/keyboards/pizzakeyboards/slice65/rules.mk
@@ -0,0 +1 @@
+MCU_LDSCRIPT = STM32F303xB