samples: tracing: Enable USB by the application

usb_enable() must be called by the application.
The application may want to register usb_dc_status_callback
and trace usb status codes (usb_dc_status_code).

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
This commit is contained in:
Emil Obalski 2020-08-03 11:36:50 +02:00 committed by Carles Cufí
commit 3758a3d4f9
2 changed files with 12 additions and 9 deletions

View file

@ -7,6 +7,8 @@
#include <zephyr.h>
#include <sys/printk.h>
#include <logging/log.h>
#include <usb/usb_device.h>
/*
* The hello world demo has two threads that utilize semaphores and sleeping
@ -85,6 +87,16 @@ void threadA(void *dummy1, void *dummy2, void *dummy3)
ARG_UNUSED(dummy2);
ARG_UNUSED(dummy3);
#if (defined(CONFIG_USB) && defined(CONFIG_USB_DEVICE_STACK))
int ret;
ret = usb_enable(NULL);
if (ret) {
printk("usb backend enable failed");
return;
}
#endif /* CONFIG_USB */
/* spawn threadB */
k_tid_t tid = k_thread_create(&threadB_data, threadB_stack_area,
STACKSIZE, threadB, NULL, NULL, NULL,

View file

@ -167,16 +167,7 @@ static void tracing_backend_usb_output(const struct tracing_backend *backend,
}
}
static void tracing_backend_usb_init(void)
{
int ret;
ret = usb_enable(NULL);
__ASSERT(ret == 0, "usb backend enable failed");
}
const struct tracing_backend_api tracing_backend_usb_api = {
.init = tracing_backend_usb_init,
.output = tracing_backend_usb_output
};