Files
new_kbd/src/events/usb_hid_event.c

47 lines
1.5 KiB
C
Raw Normal View History

#include "usb_hid_event.h"
static const char *const usb_hid_evt_type_name[] = {
[USB_HID_EVT_STATE_REPORT] = "STATE_REPORT",
};
static const char *const usb_hid_usbd_state_name[] = {
[USB_HID_USBD_DISCONNECTED] = "DISCONNECTED",
[USB_HID_USBD_CONNECTED] = "CONNECTED",
[USB_HID_USBD_SUSPENDED] = "SUSPENDED",
};
static void log_usb_hid_event(const struct app_event_header *aeh)
{
const struct usb_hid_event *event = cast_usb_hid_event(aeh);
__ASSERT_NO_MSG(event->evt_type < ARRAY_SIZE(usb_hid_evt_type_name));
__ASSERT_NO_MSG(event->usbd_state < ARRAY_SIZE(usb_hid_usbd_state_name));
APP_EVENT_MANAGER_LOG(aeh, "type=%s en=%u usbd=%s",
usb_hid_evt_type_name[event->evt_type],
event->enable,
usb_hid_usbd_state_name[event->usbd_state]);
}
static void profile_usb_hid_event(struct log_event_buf *buf,
const struct app_event_header *aeh)
{
const struct usb_hid_event *event = cast_usb_hid_event(aeh);
nrf_profiler_log_encode_uint8(buf, (uint8_t)event->evt_type);
nrf_profiler_log_encode_uint8(buf, (uint8_t)event->enable);
nrf_profiler_log_encode_uint8(buf, (uint8_t)event->usbd_state);
}
APP_EVENT_INFO_DEFINE(usb_hid_event,
ENCODE(NRF_PROFILER_ARG_U8,
NRF_PROFILER_ARG_U8,
NRF_PROFILER_ARG_U8),
ENCODE("evt_type", "enable", "usbd"),
profile_usb_hid_event);
APP_EVENT_TYPE_DEFINE(usb_hid_event,
log_usb_hid_event,
&usb_hid_event_info,
APP_EVENT_FLAGS_CREATE(APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));