59 lines
1.9 KiB
C
59 lines
1.9 KiB
C
|
|
#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 const char *const usb_hid_stack_state_name[] = {
|
||
|
|
[USB_HID_STACK_OFF] = "OFF",
|
||
|
|
[USB_HID_STACK_READY] = "READY",
|
||
|
|
[USB_HID_STACK_ACTIVE] = "ACTIVE",
|
||
|
|
[USB_HID_STACK_SUSPENDED] = "SUSPENDED",
|
||
|
|
[USB_HID_STACK_ERROR] = "ERROR",
|
||
|
|
};
|
||
|
|
|
||
|
|
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));
|
||
|
|
__ASSERT_NO_MSG(event->hid_state < ARRAY_SIZE(usb_hid_stack_state_name));
|
||
|
|
|
||
|
|
APP_EVENT_MANAGER_LOG(aeh, "type=%s en=%u usbd=%s hid=%s",
|
||
|
|
usb_hid_evt_type_name[event->evt_type],
|
||
|
|
event->enable,
|
||
|
|
usb_hid_usbd_state_name[event->usbd_state],
|
||
|
|
usb_hid_stack_state_name[event->hid_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);
|
||
|
|
nrf_profiler_log_encode_uint8(buf, (uint8_t)event->hid_state);
|
||
|
|
}
|
||
|
|
|
||
|
|
APP_EVENT_INFO_DEFINE(usb_hid_event,
|
||
|
|
ENCODE(NRF_PROFILER_ARG_U8,
|
||
|
|
NRF_PROFILER_ARG_U8,
|
||
|
|
NRF_PROFILER_ARG_U8,
|
||
|
|
NRF_PROFILER_ARG_U8),
|
||
|
|
ENCODE("evt_type", "enable", "usbd", "hid"),
|
||
|
|
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));
|