Address comments
This commit is contained in:
parent
e92a98625a
commit
f357aeddc8
4 changed files with 25 additions and 37 deletions
29
app/Kconfig
29
app/Kconfig
|
@ -238,26 +238,21 @@ menuconfig ZMK_SPLIT_SERIAL_ROLE_CENTRAL
|
|||
menuconfig ZMK_SPLIT_SERIAL_ROLE_PERIPHERAL
|
||||
bool "Peripheral"
|
||||
|
||||
if ZMK_SPLIT_SERIAL_ROLE_PERIPHERAL
|
||||
|
||||
config ZMK_SPLIT_SERIAL_PERIPHERAL_STACK_SIZE
|
||||
int "Serial split peripheral notify thread stack size"
|
||||
default 512
|
||||
|
||||
config ZMK_SPLIT_SERIAL_PERIPHERAL_PRIORITY
|
||||
int "Serial split peripheral notify thread priority"
|
||||
default 5
|
||||
|
||||
config ZMK_SPLIT_SERIAL_PERIPHERAL_POSITION_QUEUE_SIZE
|
||||
int "Max number of key position state events to queue to send to the central"
|
||||
default 10
|
||||
|
||||
# ZMK_SPLIT_SERIAL_ROLE_PERIPHERAL
|
||||
endif
|
||||
|
||||
# ZMK_SPLIT_SERIAL_ROLE
|
||||
endchoice
|
||||
|
||||
config ZMK_SPLIT_SERIAL_THREAD_STACK_SIZE
|
||||
int "Serial split thread stack size"
|
||||
default 128
|
||||
|
||||
config ZMK_SPLIT_SERIAL_THREAD_PRIORITY
|
||||
int "Serial split thread priority"
|
||||
default 5
|
||||
|
||||
config ZMK_SPLIT_SERIAL_THREAD_QUEUE_SIZE
|
||||
int "Max number of queue size for split data buffering"
|
||||
default 5
|
||||
|
||||
# ZMK_SPLIT_SERIAL
|
||||
endif
|
||||
|
||||
|
|
|
@ -3,10 +3,8 @@
|
|||
|
||||
if SHIELD_A_DUX_LEFT || SHIELD_A_DUX_RIGHT
|
||||
|
||||
if ZMK_BLE || ZMK_USB
|
||||
config ZMK_SPLIT
|
||||
default y
|
||||
endif
|
||||
|
||||
if SHIELD_A_DUX_LEFT
|
||||
|
||||
|
|
|
@ -19,28 +19,25 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
|||
#include <zmk/events/position_state_changed.h>
|
||||
#include <zmk/matrix.h>
|
||||
|
||||
#if DT_HAS_CHOSEN(zmk_split_serial)
|
||||
#if !DT_HAS_CHOSEN(zmk_split_serial)
|
||||
#error "No zmk-split-serial node is chosen"
|
||||
#endif
|
||||
|
||||
#define UART_NODE1 DT_CHOSEN(zmk_split_serial)
|
||||
const struct device *serial_dev = DEVICE_DT_GET(UART_NODE1);
|
||||
static int uart_ready = 0;
|
||||
|
||||
#define CONFIG_ZMK_SPLIT_SERIAL_CENTRAL_POSITION_QUEUE_SIZE 5
|
||||
|
||||
#define CONFIG_SERIAL_THREAD_STACK_SIZE 128
|
||||
#define CONFIG_SERIAL_THREAD_PRIORITY 5
|
||||
|
||||
static void split_serial_receive_thread(void *unused, void *unused1, void *unused2);
|
||||
|
||||
K_MEM_SLAB_DEFINE(split_memory_slab, sizeof(split_data_t), \
|
||||
CONFIG_ZMK_SPLIT_SERIAL_CENTRAL_POSITION_QUEUE_SIZE, 4);
|
||||
CONFIG_ZMK_SPLIT_SERIAL_THREAD_QUEUE_SIZE, 4);
|
||||
|
||||
K_MSGQ_DEFINE(peripheral_event_msgq, sizeof(struct zmk_position_state_changed), \
|
||||
CONFIG_ZMK_SPLIT_SERIAL_CENTRAL_POSITION_QUEUE_SIZE, 4);
|
||||
CONFIG_ZMK_SPLIT_SERIAL_THREAD_QUEUE_SIZE, 4);
|
||||
|
||||
K_THREAD_DEFINE(split_central, CONFIG_SERIAL_THREAD_STACK_SIZE,
|
||||
K_THREAD_DEFINE(split_central, CONFIG_ZMK_SPLIT_SERIAL_THREAD_STACK_SIZE,
|
||||
split_serial_receive_thread, NULL, NULL, NULL,
|
||||
K_PRIO_PREEMPT(CONFIG_SERIAL_THREAD_PRIORITY), 0, 0);
|
||||
K_PRIO_PREEMPT(CONFIG_ZMK_SPLIT_SERIAL_THREAD_PRIORITY), 0, 0);
|
||||
|
||||
|
||||
static void peripheral_event_work_callback(struct k_work *work) {
|
||||
|
@ -186,5 +183,3 @@ static void split_serial_receive_thread(void *unused, void *unused1, void *unuse
|
|||
};
|
||||
}
|
||||
|
||||
#endif /* DT_HAS_CHOSEN(zmk_matrix_transform) */
|
||||
|
||||
|
|
|
@ -18,7 +18,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
|||
|
||||
#include <zmk/matrix.h>
|
||||
|
||||
#if DT_HAS_CHOSEN(zmk_split_serial)
|
||||
#if !DT_HAS_CHOSEN(zmk_split_serial)
|
||||
#error "No zmk-split-serial node is chosen"
|
||||
#endif
|
||||
|
||||
#define UART_NODE1 DT_CHOSEN(zmk_split_serial)
|
||||
const struct device *serial_dev = DEVICE_DT_GET(UART_NODE1);
|
||||
|
@ -26,12 +28,12 @@ static int uart_ready = 0;
|
|||
|
||||
static uint8_t position_state[SPLIT_DATA_LEN];
|
||||
|
||||
K_THREAD_STACK_DEFINE(service_q_stack, CONFIG_ZMK_SPLIT_SERIAL_PERIPHERAL_STACK_SIZE);
|
||||
K_THREAD_STACK_DEFINE(service_q_stack, CONFIG_ZMK_SPLIT_SERIAL_THREAD_STACK_SIZE);
|
||||
|
||||
struct k_work_q service_work_q;
|
||||
|
||||
K_MSGQ_DEFINE(position_state_msgq, sizeof(char[SPLIT_DATA_LEN]),
|
||||
CONFIG_ZMK_SPLIT_SERIAL_PERIPHERAL_POSITION_QUEUE_SIZE, 4);
|
||||
CONFIG_ZMK_SPLIT_SERIAL_THREAD_QUEUE_SIZE, 4);
|
||||
|
||||
|
||||
void send_data_via_uart(const struct device *dev, char *data, size_t len) {
|
||||
|
@ -95,12 +97,10 @@ int service_init(const struct device *_arg) {
|
|||
uart_ready = 1;
|
||||
LOG_INF("UART device:%s ready", serial_dev->name);
|
||||
k_work_q_start(&service_work_q, service_q_stack, K_THREAD_STACK_SIZEOF(service_q_stack),
|
||||
CONFIG_ZMK_SPLIT_SERIAL_PERIPHERAL_PRIORITY);
|
||||
CONFIG_ZMK_SPLIT_SERIAL_THREAD_PRIORITY);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(service_init, APPLICATION, CONFIG_ZMK_USB_INIT_PRIORITY);
|
||||
|
||||
#endif /* DT_HAS_CHOSEN(zmk_matrix_transform) */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue