Clang formatter changes
This commit is contained in:
parent
f357aeddc8
commit
ace8cc307e
4 changed files with 49 additions and 58 deletions
|
@ -21,4 +21,3 @@ typedef struct _split_data_t {
|
||||||
int zmk_split_position_pressed(uint8_t position);
|
int zmk_split_position_pressed(uint8_t position);
|
||||||
|
|
||||||
int zmk_split_position_released(uint8_t position);
|
int zmk_split_position_released(uint8_t position);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 The ZMK Contributors
|
* Copyright (c) 2022 The ZMK Contributors
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zmk/split/common.h>
|
#include <zmk/split/common.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
|
@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||||
#include <zmk/matrix.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"
|
#error "No zmk-split-serial node is chosen"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define UART_NODE1 DT_CHOSEN(zmk_split_serial)
|
#define UART_NODE1 DT_CHOSEN(zmk_split_serial)
|
||||||
|
@ -29,17 +29,16 @@ static int uart_ready = 0;
|
||||||
|
|
||||||
static void split_serial_receive_thread(void *unused, void *unused1, void *unused2);
|
static void split_serial_receive_thread(void *unused, void *unused1, void *unused2);
|
||||||
|
|
||||||
K_MEM_SLAB_DEFINE(split_memory_slab, sizeof(split_data_t), \
|
K_MEM_SLAB_DEFINE(split_memory_slab, sizeof(split_data_t),
|
||||||
CONFIG_ZMK_SPLIT_SERIAL_THREAD_QUEUE_SIZE, 4);
|
CONFIG_ZMK_SPLIT_SERIAL_THREAD_QUEUE_SIZE, 4);
|
||||||
|
|
||||||
K_MSGQ_DEFINE(peripheral_event_msgq, sizeof(struct zmk_position_state_changed), \
|
K_MSGQ_DEFINE(peripheral_event_msgq, sizeof(struct zmk_position_state_changed),
|
||||||
CONFIG_ZMK_SPLIT_SERIAL_THREAD_QUEUE_SIZE, 4);
|
CONFIG_ZMK_SPLIT_SERIAL_THREAD_QUEUE_SIZE, 4);
|
||||||
|
|
||||||
K_THREAD_DEFINE(split_central, CONFIG_ZMK_SPLIT_SERIAL_THREAD_STACK_SIZE,
|
K_THREAD_DEFINE(split_central, CONFIG_ZMK_SPLIT_SERIAL_THREAD_STACK_SIZE,
|
||||||
split_serial_receive_thread, NULL, NULL, NULL,
|
split_serial_receive_thread, NULL, NULL, NULL,
|
||||||
K_PRIO_PREEMPT(CONFIG_ZMK_SPLIT_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) {
|
static void peripheral_event_work_callback(struct k_work *work) {
|
||||||
struct zmk_position_state_changed ev;
|
struct zmk_position_state_changed ev;
|
||||||
while (k_msgq_get(&peripheral_event_msgq, &ev, K_NO_WAIT) == 0) {
|
while (k_msgq_get(&peripheral_event_msgq, &ev, K_NO_WAIT) == 0) {
|
||||||
|
@ -64,7 +63,6 @@ static uint8_t split_central_notify_func(const void *data, uint16_t length) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < SPLIT_DATA_LEN; i++) {
|
for (int i = 0; i < SPLIT_DATA_LEN; i++) {
|
||||||
changed_positions[i] = split_data->data[i] ^ position_state[i];
|
changed_positions[i] = split_data->data[i] ^ position_state[i];
|
||||||
position_state[i] = split_data->data[i];
|
position_state[i] = split_data->data[i];
|
||||||
|
@ -102,12 +100,10 @@ static char *alloc_position_state_buffer() {
|
||||||
return block_ptr;
|
return block_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void free_position_state_buffer(char *block_ptr) {
|
static void free_position_state_buffer(char *block_ptr) {
|
||||||
k_mem_slab_free(&split_memory_slab, (void **)&block_ptr);
|
k_mem_slab_free(&split_memory_slab, (void **)&block_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void uart_callback(const struct device *dev, struct uart_event *evt, void *user_data) {
|
static void uart_callback(const struct device *dev, struct uart_event *evt, void *user_data) {
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
|
|
||||||
|
@ -146,7 +142,6 @@ static void uart_callback(const struct device *dev, struct uart_event *evt, void
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void split_serial_receive_thread(void *unused, void *unused1, void *unused2) {
|
static void split_serial_receive_thread(void *unused, void *unused1, void *unused2) {
|
||||||
if (!device_is_ready(serial_dev)) {
|
if (!device_is_ready(serial_dev)) {
|
||||||
LOG_WRN("UART device:%s not ready", serial_dev->name);
|
LOG_WRN("UART device:%s not ready", serial_dev->name);
|
||||||
|
@ -162,7 +157,7 @@ static void split_serial_receive_thread(void *unused, void *unused1, void *unuse
|
||||||
uart_ready = 1;
|
uart_ready = 1;
|
||||||
LOG_DBG("UART device:%s ready", serial_dev->name);
|
LOG_DBG("UART device:%s ready", serial_dev->name);
|
||||||
|
|
||||||
while(true) {
|
while (true) {
|
||||||
char *buf = alloc_position_state_buffer();
|
char *buf = alloc_position_state_buffer();
|
||||||
if (NULL == buf) {
|
if (NULL == buf) {
|
||||||
k_msleep(100);
|
k_msleep(100);
|
||||||
|
@ -182,4 +177,3 @@ static void split_serial_receive_thread(void *unused, void *unused1, void *unuse
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 The ZMK Contributors
|
* Copyright (c) 2022 The ZMK Contributors
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zmk/split/common.h>
|
#include <zmk/split/common.h>
|
||||||
#include <sys/util.h>
|
#include <sys/util.h>
|
||||||
|
@ -19,7 +19,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||||
#include <zmk/matrix.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"
|
#error "No zmk-split-serial node is chosen"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define UART_NODE1 DT_CHOSEN(zmk_split_serial)
|
#define UART_NODE1 DT_CHOSEN(zmk_split_serial)
|
||||||
|
@ -35,13 +35,12 @@ struct k_work_q service_work_q;
|
||||||
K_MSGQ_DEFINE(position_state_msgq, sizeof(char[SPLIT_DATA_LEN]),
|
K_MSGQ_DEFINE(position_state_msgq, sizeof(char[SPLIT_DATA_LEN]),
|
||||||
CONFIG_ZMK_SPLIT_SERIAL_THREAD_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) {
|
void send_data_via_uart(const struct device *dev, char *data, size_t len) {
|
||||||
if (!uart_ready) {
|
if (!uart_ready) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
uart_poll_out(serial_dev, data[i]);
|
uart_poll_out(serial_dev, data[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,4 +102,3 @@ int service_init(const struct device *_arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SYS_INIT(service_init, APPLICATION, CONFIG_ZMK_USB_INIT_PRIORITY);
|
SYS_INIT(service_init, APPLICATION, CONFIG_ZMK_USB_INIT_PRIORITY);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue