#include <zephyr/device.h>
#include <zephyr/drivers/uart.h>
#include <zephyr/input/input.h>
#include <zephyr/irq.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/time_units.h>
#include <zephyr/sys_clock.h>
◆ CHANNEL_VALUE_ONE
#define CHANNEL_VALUE_ONE CONFIG_INPUT_DBUS_CHANNEL_VALUE_ONE |
◆ CHANNEL_VALUE_ZERO
#define CHANNEL_VALUE_ZERO CONFIG_INPUT_DBUS_CHANNEL_VALUE_ZERO |
◆ DBUS_CHANNEL_COUNT
#define DBUS_CHANNEL_COUNT 28 /* 通道总数:5个摇杆+2个开关+4个鼠标+1个滚轮+16个键盘 */ |
◆ DBUS_FRAME_LEN
#define DBUS_FRAME_LEN 18 |
◆ DBUS_INPUT_CHANNEL_INITIALIZER
#define DBUS_INPUT_CHANNEL_INITIALIZER |
( |
| input_channel_id | ) |
|
值: { \
.dbus_channel = DT_PROP(input_channel_id, channel), \
.type = DT_PROP(input_channel_id, type), \
.zephyr_code = DT_PROP(input_channel_id, zephyr_code), \
},
◆ DBUS_INTERFRAME_SPACING_MS
#define DBUS_INTERFRAME_SPACING_MS 20 |
◆ DBUS_TRANSMISSION_TIME_MS
#define DBUS_TRANSMISSION_TIME_MS 4 |
◆ DT_DRV_COMPAT
#define DT_DRV_COMPAT dji_dbus |
◆ INPUT_CHANNEL_CHECK
#define INPUT_CHANNEL_CHECK |
( |
| input_channel_id | ) |
|
值: BUILD_ASSERT(IN_RANGE(DT_PROP(input_channel_id, channel), 0, 26), "无效的通道号"); \
BUILD_ASSERT(DT_PROP(input_channel_id, type) == INPUT_EV_ABS || DT_PROP(input_channel_id, type) == INPUT_EV_KEY || \
DT_PROP(input_channel_id, type) == INPUT_EV_MSC, \
"无效的通道类型");
◆ INPUT_DBUS_INIT
#define INPUT_DBUS_INIT |
( |
| n | ) |
|
值: \
\
\
.channel_info = input_##n, \
.uart_dev = DEVICE_DT_GET(DT_INST_BUS(n)), \
.num_channels = ARRAY_SIZE(input_##n), \
}; \
\
DEVICE_DT_INST_DEFINE(n,
input_dbus_init, NULL, &dbus_data_##n, &dbus_cfg_##n, POST_KERNEL, \
CONFIG_INPUT_INIT_PRIORITY, NULL);
◆ RC_CH_VALUE_OFFSET
#define RC_CH_VALUE_OFFSET 1024 |
◆ REPORT_FILTER
#define REPORT_FILTER CONFIG_INPUT_DBUS_REPORT_FILTER |
◆ dbus_uart_isr()
static void dbus_uart_isr |
( |
const struct device * | uart_dev, |
|
|
void * | user_data ) |
|
static |
◆ input_dbus_init()
static int input_dbus_init |
( |
const struct device * | dev | ) |
|
|
static |
◆ input_dbus_input_report_thread()
static void input_dbus_input_report_thread |
( |
const struct device * | dev, |
|
|
void * | dummy2, |
|
|
void * | dummy3 ) |
|
static |
◆ input_dbus_report()
static void input_dbus_report |
( |
const struct device * | dev, |
|
|
unsigned int | dbus_channel, |
|
|
unsigned int | value ) |
|
static |
◆ LOG_MODULE_REGISTER()
LOG_MODULE_REGISTER |
( |
dji_dbus | , |
|
|
CONFIG_INPUT_LOG_LEVEL | ) |
◆ uart_cfg_dbus
const struct uart_config uart_cfg_dbus |
初始值:= {.baudrate = 100000,
.parity = UART_CFG_PARITY_EVEN,
.stop_bits = UART_CFG_STOP_BITS_2,
.data_bits = UART_CFG_DATA_BITS_8,
.flow_ctrl = UART_CFG_FLOW_CTRL_NONE}