forked from kofal.net/zmk
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:
@@ -148,21 +148,30 @@ void zmk_split_wired_async_tx(struct zmk_split_wired_async_state *state) {
|
||||
}
|
||||
}
|
||||
|
||||
static void restart_rx_work_cb(struct k_work *work) {
|
||||
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
|
||||
struct zmk_split_wired_async_state *state =
|
||||
CONTAINER_OF(dwork, struct zmk_split_wired_async_state, restart_rx_work);
|
||||
int zmk_split_wired_async_rx(struct zmk_split_wired_async_state *state) {
|
||||
|
||||
atomic_set_bit(&state->state, ASYNC_STATE_BIT_RXBUF0_USED);
|
||||
atomic_clear_bit(&state->state, ASYNC_STATE_BIT_RXBUF1_USED);
|
||||
|
||||
LOG_WRN("RESTART!");
|
||||
|
||||
int ret = uart_rx_enable(state->uart, state->rx_bufs[0], state->rx_bufs_len,
|
||||
CONFIG_ZMK_SPLIT_WIRED_ASYNC_RX_TIMEOUT);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Failed to enable RX (%d)", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int zmk_split_wired_async_rx_cancel(struct zmk_split_wired_async_state *state) {
|
||||
return uart_rx_disable(state->uart);
|
||||
}
|
||||
|
||||
static void restart_rx_work_cb(struct k_work *work) {
|
||||
struct k_work_delayable *dwork = k_work_delayable_from_work(work);
|
||||
struct zmk_split_wired_async_state *state =
|
||||
CONTAINER_OF(dwork, struct zmk_split_wired_async_state, restart_rx_work);
|
||||
|
||||
zmk_split_wired_async_rx(state);
|
||||
}
|
||||
|
||||
static void async_uart_cb(const struct device *dev, struct uart_event *ev, void *user_data) {
|
||||
@@ -247,14 +256,14 @@ int zmk_split_wired_async_init(struct zmk_split_wired_async_state *state) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
atomic_set_bit(&state->state, ASYNC_STATE_BIT_RXBUF0_USED);
|
||||
// atomic_set_bit(&state->state, ASYNC_STATE_BIT_RXBUF0_USED);
|
||||
|
||||
ret = uart_rx_enable(state->uart, state->rx_bufs[0], state->rx_bufs_len,
|
||||
CONFIG_ZMK_SPLIT_WIRED_ASYNC_RX_TIMEOUT);
|
||||
if (ret < 0) {
|
||||
LOG_ERR("Failed to enable RX (%d)", ret);
|
||||
return ret;
|
||||
}
|
||||
// ret = uart_rx_enable(state->uart, state->rx_bufs[0], state->rx_bufs_len,
|
||||
// CONFIG_ZMK_SPLIT_WIRED_ASYNC_RX_TIMEOUT);
|
||||
// if (ret < 0) {
|
||||
// LOG_ERR("Failed to enable RX (%d)", ret);
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user