55 lines
1.5 KiB
C
55 lines
1.5 KiB
C
|
|
#include <caf/events/module_state_event.h>
|
||
|
|
|
||
|
|
#include "usb_state_event.h"
|
||
|
|
|
||
|
|
static const char *usb_state_event_op_name(uint8_t op)
|
||
|
|
{
|
||
|
|
switch ((enum usb_state_event_op)op) {
|
||
|
|
case USB_STATE_EVENT_OP_SET_BITS:
|
||
|
|
return "set_bits";
|
||
|
|
case USB_STATE_EVENT_OP_CLEAR_BITS:
|
||
|
|
return "clear_bits";
|
||
|
|
case USB_STATE_EVENT_OP_SNAPSHOT:
|
||
|
|
return "snapshot";
|
||
|
|
default:
|
||
|
|
return "?";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
static const char *module_name_or_any(const void *module_id)
|
||
|
|
{
|
||
|
|
return (module_id != NULL) ? module_name_get(module_id) : "*";
|
||
|
|
}
|
||
|
|
|
||
|
|
static void log_usb_state_event(const struct app_event_header *aeh)
|
||
|
|
{
|
||
|
|
const struct usb_state_event *event = cast_usb_state_event(aeh);
|
||
|
|
|
||
|
|
APP_EVENT_MANAGER_LOG(aeh,
|
||
|
|
"src:%s sink:%s op:%s flags:0x%08x",
|
||
|
|
module_name_or_any(event->src_module_id),
|
||
|
|
module_name_or_any(event->sink_module_id),
|
||
|
|
usb_state_event_op_name(event->op),
|
||
|
|
event->flags);
|
||
|
|
}
|
||
|
|
|
||
|
|
static void profile_usb_state_event(struct log_event_buf *buf,
|
||
|
|
const struct app_event_header *aeh)
|
||
|
|
{
|
||
|
|
const struct usb_state_event *event = cast_usb_state_event(aeh);
|
||
|
|
|
||
|
|
nrf_profiler_log_encode_uint8(buf, event->op);
|
||
|
|
nrf_profiler_log_encode_uint32(buf, event->flags);
|
||
|
|
}
|
||
|
|
|
||
|
|
APP_EVENT_INFO_DEFINE(usb_state_event,
|
||
|
|
ENCODE(NRF_PROFILER_ARG_U8, NRF_PROFILER_ARG_U32),
|
||
|
|
ENCODE("op", "flags"),
|
||
|
|
profile_usb_state_event);
|
||
|
|
|
||
|
|
APP_EVENT_TYPE_DEFINE(usb_state_event,
|
||
|
|
log_usb_state_event,
|
||
|
|
&usb_state_event_info,
|
||
|
|
APP_EVENT_FLAGS_CREATE(
|
||
|
|
APP_EVENT_TYPE_FLAGS_INIT_LOG_ENABLE));
|