feat(split): Runtime selection of split transport (#2886)

feat(split): Runtime selection of split transport

Allow building multiple split transports, and select an active
one based on the transport availability. Wired split availability
depends on additional `detect-gpios` which must be a GPIO pin
that goes active when a wired connection is present.

feat(split): Suspend/resume wired UART devices.

To better support runtime split support, suspend/resume the UART
as necessary to save power when not using the UART.

docs(split): Document adjusting nRF52 UART interrupt priorities

For wired split on nRF52, you may need to adjust the priority for UART
interrupts lower, to ensure the interrupts used for timing sensitive
BT operations can run when needed, so document this in our pinctrl docs.

refactor(split): Restore use of aync UART on nRF52.

With fixes for Zephyr UART driver, re-enable using async API on nRF52.

fix(split): Minor wired split fixes.

Various minor fixes for wired split to avoid spurious TX in half duplex,
etc.

fix: Unconditionally define HID payloads to avoid error.

Don't conditionally define HID indicator payload, to avoid compilation
errors.

docs(split): Expand on details of split transports.

Expand the split keyboard documentation with a more fleshed out section
on the available split trasnports, and what is and isn't supported by
each, including the runtime selection functionality.

---------

Co-authored-by: Nicolas Munnich <98408764+nmunnich@users.noreply.github.com>
This commit is contained in:
Pete Johanson 2025-06-16 01:45:25 -06:00 committed by GitHub
parent 462d48b78e
commit 6b44d33db2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 830 additions and 93 deletions

View file

@ -26,6 +26,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/split/bluetooth/uuid.h>
#include <zmk/split/bluetooth/service.h>
#include "peripheral.h"
#if IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS)
#include <zmk/events/hid_indicators_changed.h>
#endif // IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS)
@ -343,7 +345,8 @@ static int service_init(void) {
SYS_INIT(service_init, APPLICATION, CONFIG_ZMK_BLE_INIT_PRIORITY);
static int zmk_peripheral_ble_report_event(const struct zmk_split_transport_peripheral_event *ev) {
int zmk_split_transport_peripheral_bt_report_event(
const struct zmk_split_transport_peripheral_event *ev) {
switch (ev->type) {
case ZMK_SPLIT_TRANSPORT_PERIPHERAL_EVENT_TYPE_KEY_POSITION_EVENT:
if (ev->data.key_position_event.pressed) {
@ -380,12 +383,6 @@ static int zmk_peripheral_ble_report_event(const struct zmk_split_transport_peri
return 0;
}
static const struct zmk_split_transport_peripheral_api peripheral_api = {
.report_event = zmk_peripheral_ble_report_event,
};
ZMK_SPLIT_TRANSPORT_PERIPHERAL_REGISTER(bt_peripheral, &peripheral_api);
static ssize_t split_svc_run_behavior(struct bt_conn *conn, const struct bt_gatt_attr *attrs,
const void *buf, uint16_t len, uint16_t offset,
uint8_t flags) {
@ -428,7 +425,8 @@ static ssize_t split_svc_run_behavior(struct bt_conn *conn, const struct bt_gatt
cmd.data.invoke_behavior.param1, cmd.data.invoke_behavior.param2,
cmd.data.invoke_behavior.state);
int err = zmk_split_transport_peripheral_command_handler(&bt_peripheral, cmd);
int err = zmk_split_transport_peripheral_command_handler(
zmk_split_transport_peripheral_bt(), cmd);
if (err) {
LOG_ERR("Failed to invoke behavior %s: %d", payload->behavior_dev, err);