From 035d19aaa571821b9b8ebdc993bccdba204945c6 Mon Sep 17 00:00:00 2001
From: Jay Greco <jayv.greco@gmail.com>
Date: Tue, 28 Mar 2023 05:21:17 +0000
Subject: [PATCH] Update rp2040_bb with SIO

---
 keyboards/nullbitsco/rp2040_bb/config.h    | 26 ++++++++++++++--------
 keyboards/nullbitsco/rp2040_bb/halconf.h   |  1 +
 keyboards/nullbitsco/rp2040_bb/info.json   |  9 ++++++++
 keyboards/nullbitsco/rp2040_bb/mcuconf.h   |  3 +++
 keyboards/nullbitsco/rp2040_bb/rp2040_bb.c | 23 ++++++++++++++++---
 keyboards/nullbitsco/rp2040_bb/rules.mk    |  2 ++
 6 files changed, 52 insertions(+), 12 deletions(-)
 create mode 100644 keyboards/nullbitsco/rp2040_bb/info.json

diff --git a/keyboards/nullbitsco/rp2040_bb/config.h b/keyboards/nullbitsco/rp2040_bb/config.h
index afbdfeeb31..1df39ee900 100644
--- a/keyboards/nullbitsco/rp2040_bb/config.h
+++ b/keyboards/nullbitsco/rp2040_bb/config.h
@@ -19,13 +19,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include "config_common.h"
 
-/* USB Device descriptor parameter */
-#define VENDOR_ID       0x6E61
-#define PRODUCT_ID      0x6069
-#define DEVICE_VER      0x0001
-#define MANUFACTURER    nullbits
-#define PRODUCT         RP2040_BB
-
 /* key matrix size */
 #define MATRIX_COLS 2
 #define MATRIX_ROWS 3
@@ -37,14 +30,28 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define MATRIX_COL_PINS { GP4, GP5 }
 #define MATRIX_ROW_PINS { GP6, GP7, GP8 }
 
+/* RP2040 definitions */
 #define RP2040_FLASH_W25X10CL
+#define RMKB_SIO_DRIVER SIOD0
+#define RMKB_SIO_TX_PIN GP0
+#define RMKB_SIO_RX_PIN GP1
 
 /* Optional SMT LED pins */
 #define RGB_DI_PIN GP19
 #define RGBLED_NUM 8
 #define RGBLIGHT_DEFAULT_VAL 64
 #define RGBLIGHT_DEFAULT_MODE 10
-#define RGBLIGHT_ANIMATIONS 
+#define RGBLIGHT_EFFECT_BREATHING
+#define RGBLIGHT_EFFECT_RAINBOW_MOOD
+#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
+#define RGBLIGHT_EFFECT_SNAKE
+#define RGBLIGHT_EFFECT_KNIGHT
+#define RGBLIGHT_EFFECT_CHRISTMAS
+#define RGBLIGHT_EFFECT_STATIC_GRADIENT
+#define RGBLIGHT_EFFECT_RGB_TEST
+#define RGBLIGHT_EFFECT_ALTERNATING
+#define RGBLIGHT_EFFECT_TWINKLE
+#define RGBLIGHT_SLEEP
 
 /* Optional encoder pins */
 #define ENCODERS_PAD_A { GP23 }
@@ -56,4 +63,5 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define I2C_DRIVER I2CD2
 
 /* Debug configs */
-#define DEBUG_MATRIX_SCAN_RATE
+// #define DEBUG_MATRIX_SCAN_RATE
+// #define KEYBOARD_REMOTE
diff --git a/keyboards/nullbitsco/rp2040_bb/halconf.h b/keyboards/nullbitsco/rp2040_bb/halconf.h
index c4a7101379..2cd9db10ff 100644
--- a/keyboards/nullbitsco/rp2040_bb/halconf.h
+++ b/keyboards/nullbitsco/rp2040_bb/halconf.h
@@ -1,5 +1,6 @@
 #pragma once
 
 #define HAL_USE_I2C TRUE
+#define HAL_USE_SIO TRUE
 
 #include_next <halconf.h>
diff --git a/keyboards/nullbitsco/rp2040_bb/info.json b/keyboards/nullbitsco/rp2040_bb/info.json
new file mode 100644
index 0000000000..005604feb1
--- /dev/null
+++ b/keyboards/nullbitsco/rp2040_bb/info.json
@@ -0,0 +1,9 @@
+{
+    "keyboard_name": "RP2040_BB",
+    "manufacturer": "nullbits",
+    "usb": {
+        "vid": "0x6E61",
+        "pid": "0x6069",
+        "device_version": "0.0.1"
+    }
+}
diff --git a/keyboards/nullbitsco/rp2040_bb/mcuconf.h b/keyboards/nullbitsco/rp2040_bb/mcuconf.h
index 4e812fc705..01d7d52875 100644
--- a/keyboards/nullbitsco/rp2040_bb/mcuconf.h
+++ b/keyboards/nullbitsco/rp2040_bb/mcuconf.h
@@ -4,3 +4,6 @@
 
 #undef RP_I2C_USE_I2C1
 #define RP_I2C_USE_I2C1 TRUE
+
+#undef RP_SIO_USE_UART0
+#define RP_SIO_USE_UART0 TRUE
diff --git a/keyboards/nullbitsco/rp2040_bb/rp2040_bb.c b/keyboards/nullbitsco/rp2040_bb/rp2040_bb.c
index f8c42a1107..156fb6f62b 100644
--- a/keyboards/nullbitsco/rp2040_bb/rp2040_bb.c
+++ b/keyboards/nullbitsco/rp2040_bb/rp2040_bb.c
@@ -1,11 +1,28 @@
-// Copyright 2022 Stefan Kerkmann
+// Copyright 2022 Jay Greco
 // SPDX-License-Identifier: GPL-2.0-or-later
 
 #include QMK_KEYBOARD_H
+#include "common/remote_kb.h"
 
 void keyboard_post_init_user(void) {
     debug_enable   = true;
     debug_matrix   = true;
-    debug_keyboard = true;
-    debug_mouse    = true;
+    // debug_keyboard = true;
+    // debug_mouse    = true;
+}
+
+bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
+    process_record_remote_kb(keycode, record);
+    if (!process_record_user(keycode, record)) return false;
+    return true;
+}
+
+void matrix_init_kb(void) {
+    matrix_init_remote_kb();
+    matrix_init_user();
+}
+
+void matrix_scan_kb(void) {
+    matrix_scan_remote_kb();
+    matrix_scan_user();
 }
diff --git a/keyboards/nullbitsco/rp2040_bb/rules.mk b/keyboards/nullbitsco/rp2040_bb/rules.mk
index b04b1a90d9..4595f01acd 100644
--- a/keyboards/nullbitsco/rp2040_bb/rules.mk
+++ b/keyboards/nullbitsco/rp2040_bb/rules.mk
@@ -20,3 +20,5 @@ VIA_ENABLE = yes
 ENCODER_ENABLE = yes
 RGBLIGHT_ENABLE = yes
 AUDIO_ENABLE = no #not yet supported
+
+SRC += common/remote_kb.c
-- 
GitLab