feat(split): wired split over serial TX support (WIP 2024-05-26)
This commit is contained in:
parent
233b63d637
commit
fa721e8b2c
3 changed files with 36 additions and 1 deletions
|
@ -1,6 +1,10 @@
|
||||||
# Copyright (c) 2023 The ZMK Contributors
|
# Copyright (c) 2023 The ZMK Contributors
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
if (NOT CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
|
||||||
|
target_sources(app PRIVATE peripheral.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
|
if (CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
|
||||||
target_sources(app PRIVATE central.c)
|
target_sources(app PRIVATE central.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
24
app/src/split/serial/peripheral.c
Normal file
24
app/src/split/serial/peripheral.c
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 The ZMK Contributors
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <zephyr/kernel.h>
|
||||||
|
|
||||||
|
#include <zmk/split/serial/serial.h>
|
||||||
|
|
||||||
|
// TODO TODO TODO
|
||||||
|
#include <zephyr/logging/log.h>
|
||||||
|
LOG_MODULE_DECLARE(slicemk);
|
||||||
|
|
||||||
|
// TODO TODO TODO these two should be in a header somewhere
|
||||||
|
|
||||||
|
// TODO TODO TODO implement central to peripheral data transfer
|
||||||
|
void serial_handle_rx(uint32_t cmd, uint8_t *data, uint8_t len) {
|
||||||
|
LOG_HEXDUMP_ERR(data, len, "central to peripheral");
|
||||||
|
}
|
||||||
|
|
||||||
|
void send_position_state_impl(uint8_t *state, int len) {
|
||||||
|
serial_write_uart(0x73627400, state, len);
|
||||||
|
}
|
|
@ -117,7 +117,7 @@ static void serial_callback(const struct device *dev, void *data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_write(struct serial_device *sd, uint32_t cmd, uint8_t *data, uint8_t len) {
|
static void serial_write(struct serial_device *sd, uint32_t cmd, uint8_t *data, uint8_t len) {
|
||||||
// TODO TODO TODO use buf with size SERIAL_BUF_SIZE. do single
|
// TODO TODO TODO use buf with size SERIAL_BUF_SIZE. do single
|
||||||
// ring_buf_put() to avoid potential race
|
// ring_buf_put() to avoid potential race
|
||||||
uint8_t header[13] = SERIAL_MSG_PREFIX;
|
uint8_t header[13] = SERIAL_MSG_PREFIX;
|
||||||
|
@ -138,6 +138,13 @@ void serial_write(struct serial_device *sd, uint32_t cmd, uint8_t *data, uint8_t
|
||||||
uart_irq_tx_enable(sd->dev);
|
uart_irq_tx_enable(sd->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO TODO TODO this should be abstracted a bit differently
|
||||||
|
#ifdef CONFIG_ZMK_SPLIT_SERIAL_UART
|
||||||
|
void serial_write_uart(uint32_t cmd, uint8_t *data, uint8_t len) {
|
||||||
|
serial_write(&serial_devs[0], cmd, data, len);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_ZMK_SPLIT_SERIAL_UART_POLL
|
#ifdef CONFIG_ZMK_SPLIT_SERIAL_UART_POLL
|
||||||
|
|
||||||
static void serial_tx_work_handler(struct k_work *work) {
|
static void serial_tx_work_handler(struct k_work *work) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue