Commit 3758a3d4 authored by Emil Obalski's avatar Emil Obalski Committed by Carles Cufi
Browse files

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: default avatarEmil Obalski <emil.obalski@nordicsemi.no>
parent 1d7505cd
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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,
+0 −9
Original line number Diff line number Diff line
@@ -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
};