feat(usb): 添加USB HID模块支持键盘和消费设备
- 添加USB HID模块实现键盘和消费控制设备功能 - 在CMakeLists.txt中添加usb_hid_module.c和相关事件文件 - 添加HID LED事件和设置协议事件定义及实现 - 配置设备树添加HID键盘和消费者设备节点 - 启用USB设备堆栈配置选项 - 修改键盘核心模块以处理协议切换事件 - 修复键映射中keypad enter的位置错误 - 注释掉电池模块中的调试日志输出
This commit is contained in:
27
src/events/hid_led_event.c
Normal file
27
src/events/hid_led_event.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "hid_led_event.h"
|
||||
|
||||
static void log_hid_led_event(const struct app_event_header *aeh)
|
||||
{
|
||||
const struct hid_led_event *event = cast_hid_led_event(aeh);
|
||||
|
||||
APP_EVENT_MANAGER_LOG(aeh, "led_bm:0x%02x", event->led_bm);
|
||||
}
|
||||
|
||||
static void profile_hid_led_event(struct log_event_buf *buf,
|
||||
const struct app_event_header *aeh)
|
||||
{
|
||||
const struct hid_led_event *event = cast_hid_led_event(aeh);
|
||||
|
||||
nrf_profiler_log_encode_uint8(buf, event->led_bm);
|
||||
}
|
||||
|
||||
APP_EVENT_INFO_DEFINE(hid_led_event,
|
||||
ENCODE(NRF_PROFILER_ARG_U8),
|
||||
ENCODE("led_bm"),
|
||||
profile_hid_led_event);
|
||||
|
||||
APP_EVENT_TYPE_DEFINE(hid_led_event,
|
||||
log_hid_led_event,
|
||||
&hid_led_event_info,
|
||||
APP_EVENT_FLAGS_CREATE(
|
||||
APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));
|
||||
40
src/events/set_protocol_event.c
Normal file
40
src/events/set_protocol_event.c
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "set_protocol_event.h"
|
||||
|
||||
static const char *protocol_mode_name(enum keyboard_protocol_mode protocol_mode)
|
||||
{
|
||||
switch (protocol_mode) {
|
||||
case KEYBOARD_PROTOCOL_MODE_BOOT:
|
||||
return "boot";
|
||||
case KEYBOARD_PROTOCOL_MODE_REPORT:
|
||||
return "report";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
static void log_set_protocol_event(const struct app_event_header *aeh)
|
||||
{
|
||||
const struct set_protocol_event *event = cast_set_protocol_event(aeh);
|
||||
|
||||
APP_EVENT_MANAGER_LOG(aeh, "protocol:%s",
|
||||
protocol_mode_name(event->protocol_mode));
|
||||
}
|
||||
|
||||
static void profile_set_protocol_event(struct log_event_buf *buf,
|
||||
const struct app_event_header *aeh)
|
||||
{
|
||||
const struct set_protocol_event *event = cast_set_protocol_event(aeh);
|
||||
|
||||
nrf_profiler_log_encode_uint8(buf, event->protocol_mode);
|
||||
}
|
||||
|
||||
APP_EVENT_INFO_DEFINE(set_protocol_event,
|
||||
ENCODE(NRF_PROFILER_ARG_U8),
|
||||
ENCODE("protocol_mode"),
|
||||
profile_set_protocol_event);
|
||||
|
||||
APP_EVENT_TYPE_DEFINE(set_protocol_event,
|
||||
log_set_protocol_event,
|
||||
&set_protocol_event_info,
|
||||
APP_EVENT_FLAGS_CREATE(
|
||||
APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));
|
||||
Reference in New Issue
Block a user