Commit 57084f32 authored by Emil Obalski's avatar Emil Obalski Committed by Carles Cufi
Browse files

samples: zperf: usb: Enable USB by the application.



This commit allows let build zperf sample with overlay-netusb.conf.
USB subsystem must be enabled by the application.

Signed-off-by: default avatarEmil Obalski <emil.obalski@nordicsemi.no>
parent 3758a3d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(zperf)

target_sources(app PRIVATE
  src/main.c
  src/shell_utils.c
  src/zperf_session.c
  src/zperf_shell.c
+26 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * @file
 * @brief Zperf sample.
 */
#include <usb/usb_device.h>
#include <net/net_config.h>

void main(void)
{
#if defined(CONFIG_USB)
	int ret;

	ret = usb_enable(NULL);
	if (ret != 0) {
		printk("usb enable error %d\n", ret);
	}

	(void)net_config_init_app(NULL, "Initializing network");
#endif /* CONFIG_USB */
}
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@

config NET_CONFIG_AUTO_INIT
	bool "Init networking support automatically during device startup"
	default n if USB_DEVICE_NETWORK
	default y
	help
	  If this option is set, then the networking system is automatically
+0 −8
Original line number Diff line number Diff line
@@ -125,18 +125,10 @@ bool netusb_enabled(void)

static void netusb_init(struct net_if *iface)
{
	int ret;

	static uint8_t mac[6] = { 0x00, 0x00, 0x5E, 0x00, 0x53, 0x00 };

	LOG_DBG("netusb device initialization");

	ret = usb_enable(NULL);
	if (ret != 0) {
		LOG_ERR("Failed to enable USB");
		return;
	}

	netusb.iface = iface;

	ethernet_init(iface);