feat: 添加HID流控制模块和相关事件处理
- 添加hid_flowctrl_module.c实现HID报告流控制功能,包括FIFO队列管理和 报告发送控制 - 新增hid_report_sent_event、hid_transport_state_event和 hid_tx_report_event事件类型及其对应的头文件和实现 - 在CMakeLists.txt中注册新模块和事件源文件 - 修改keyboard_core_module.c以支持队列策略,并添加编码器事件处理逻辑 - 更新usb_hid_module.c将直接的键盘HID报告事件改为通过 hid_tx_report_event进行传输,并添加状态报告事件 - 在keyboard_hid_report_event中增加queue_policy字段以支持不同 队列策略
This commit is contained in:
@@ -42,6 +42,18 @@ static const char *protocol_mode_name(enum keyboard_protocol_mode protocol_mode)
|
||||
}
|
||||
}
|
||||
|
||||
static const char *queue_policy_name(enum hid_queue_policy queue_policy)
|
||||
{
|
||||
switch (queue_policy) {
|
||||
case HID_QUEUE_POLICY_LATEST:
|
||||
return "latest";
|
||||
case HID_QUEUE_POLICY_FIFO:
|
||||
return "fifo";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
static void log_keyboard_hid_report_event(const struct app_event_header *aeh)
|
||||
{
|
||||
const struct keyboard_hid_report_event *event =
|
||||
@@ -49,10 +61,12 @@ static void log_keyboard_hid_report_event(const struct app_event_header *aeh)
|
||||
char log_buf[KEYBOARD_HID_REPORT_EVENT_LOG_BUF_LEN];
|
||||
int pos;
|
||||
|
||||
pos = snprintf(log_buf, sizeof(log_buf), "mode:%s type:%s protocol:%s len:%zu",
|
||||
pos = snprintf(log_buf, sizeof(log_buf),
|
||||
"mode:%s type:%s protocol:%s queue:%s len:%zu",
|
||||
mode_name(event->mode),
|
||||
report_type_name(event->report_type),
|
||||
protocol_mode_name(event->protocol_mode),
|
||||
queue_policy_name(event->queue_policy),
|
||||
event->dyndata.size);
|
||||
if ((pos > 0) && (pos < sizeof(log_buf))) {
|
||||
for (size_t i = 0; i < event->dyndata.size; i++) {
|
||||
@@ -89,15 +103,17 @@ static void profile_keyboard_hid_report_event(struct log_event_buf *buf,
|
||||
nrf_profiler_log_encode_uint8(buf, event->mode);
|
||||
nrf_profiler_log_encode_uint8(buf, event->report_type);
|
||||
nrf_profiler_log_encode_uint8(buf, event->protocol_mode);
|
||||
nrf_profiler_log_encode_uint8(buf, event->queue_policy);
|
||||
nrf_profiler_log_encode_uint8(buf, (uint8_t)event->dyndata.size);
|
||||
}
|
||||
|
||||
APP_EVENT_INFO_DEFINE(keyboard_hid_report_event,
|
||||
ENCODE(NRF_PROFILER_ARG_U8,
|
||||
NRF_PROFILER_ARG_U8,
|
||||
NRF_PROFILER_ARG_U8,
|
||||
NRF_PROFILER_ARG_U8,
|
||||
NRF_PROFILER_ARG_U8),
|
||||
ENCODE("mode", "report_type", "protocol_mode", "len"),
|
||||
ENCODE("mode", "report_type", "protocol_mode", "queue_policy", "len"),
|
||||
profile_keyboard_hid_report_event);
|
||||
|
||||
APP_EVENT_TYPE_DEFINE(keyboard_hid_report_event,
|
||||
|
||||
Reference in New Issue
Block a user