Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usbus/cdc/ecm: Expose configurations to Kconfig #13839

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions sys/include/usb/usbus/cdc/ecm.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ extern "C" {
* peripheral will report this to the host. This doesn't affect the actual
* throughput, only what the peripheral reports to the host.
*/
#ifndef USBUS_CDC_ECM_CONFIG_SPEED
#define USBUS_CDC_ECM_CONFIG_SPEED 1000000
#ifndef CONFIG_USBUS_CDC_ECM_CONFIG_SPEED
#define CONFIG_USBUS_CDC_ECM_CONFIG_SPEED 1000000
#endif

/**
* @brief Link download speed as reported by the peripheral
*/
#ifndef USBUS_CDC_ECM_CONFIG_SPEED_DOWNSTREAM
#define USBUS_CDC_ECM_CONFIG_SPEED_DOWNSTREAM USBUS_CDC_ECM_CONFIG_SPEED
#ifndef CONFIG_USBUS_CDC_ECM_CONFIG_SPEED_DOWNSTREAM
#define CONFIG_USBUS_CDC_ECM_CONFIG_SPEED_DOWNSTREAM CONFIG_USBUS_CDC_ECM_CONFIG_SPEED
#endif

/**
* @brief Link upload speed as reported by the peripheral
*/
#ifndef USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM
#define USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM USBUS_CDC_ECM_CONFIG_SPEED
#ifndef CONFIG_USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM
#define CONFIG_USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM CONFIG_USBUS_CDC_ECM_CONFIG_SPEED
#endif

/**
Expand Down
1 change: 1 addition & 0 deletions sys/usb/usbus/cdc/Kconfig
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
rsource "acm/Kconfig"
rsource "ecm/Kconfig"
43 changes: 43 additions & 0 deletions sys/usb/usbus/cdc/ecm/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (c) 2020 HAW Hamburg
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
menuconfig KCONFIG_MODULE_USBUS_CDC_ECM
bool "Configure USBUS CDC ECM"
depends on MODULE_USBUS_CDC_ECM
help
Configure the USBUS CDC ECM module via Kconfig.

if KCONFIG_MODULE_USBUS_CDC_ECM

config USBUS_CDC_ECM_CONFIG_SPEED_IND
bool "Configure upload and download speeds independently"

config USBUS_CDC_ECM_CONFIG_SPEED
int
prompt "Link throughput (bits/second)" if !USBUS_CDC_ECM_CONFIG_SPEED_IND
default 1000000
help
This defines a common up and down link throughput in bits/second. The
USB peripheral will report this to the host. This doesn't affect the
actual throughput, only what the peripheral reports to the host.

config USBUS_CDC_ECM_CONFIG_SPEED_DOWNSTREAM
int
prompt "Link download speed (bits/second)" if USBUS_CDC_ECM_CONFIG_SPEED_IND
default USBUS_CDC_ECM_CONFIG_SPEED
help
This is the link download speed, defined in bits/second, that the USB
peripheral will report to the host.

config USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM
int
prompt "Link upload speed (bits/second)" if USBUS_CDC_ECM_CONFIG_SPEED_IND
default USBUS_CDC_ECM_CONFIG_SPEED
help
This is the link upload speed, defined in bits/second, that the USB
peripheral will report to the host.

endif # KCONFIG_MODULE_USBUS_CDC_ECM
4 changes: 2 additions & 2 deletions sys/usb/usbus/cdc/ecm/cdc_ecm.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ static void _notify_link_speed(usbus_cdcecm_device_t *cdcecm)
notification->setup.index = cdcecm->iface_ctrl.idx;
notification->setup.length = 8;

notification->down = USBUS_CDC_ECM_CONFIG_SPEED_DOWNSTREAM;
notification->up = USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM;
notification->down = CONFIG_USBUS_CDC_ECM_CONFIG_SPEED_DOWNSTREAM;
notification->up = CONFIG_USBUS_CDC_ECM_CONFIG_SPEED_UPSTREAM;
usbdev_ep_ready(cdcecm->ep_ctrl->ep,
sizeof(usb_desc_cdcecm_speed_t));
cdcecm->notif = USBUS_CDCECM_NOTIF_SPEED;
Expand Down
5 changes: 5 additions & 0 deletions tests/usbus_cdc_ecm/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
config USB_VID
default 0x$(DEFAULT_VID) if KCONFIG_USB

config USB_PID
default 0x$(DEFAULT_PID) if KCONFIG_USB
22 changes: 18 additions & 4 deletions tests/usbus_cdc_ecm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,29 @@ USEMODULE += ps

# USB device vendor and product ID
# pid.codes test VID/PID, not globally unique
DEFAULT_VID = 1209
DEFAULT_PID = 7D00
export DEFAULT_VID = 1209
export DEFAULT_PID = 7D00
USB_VID ?= $(DEFAULT_VID)
USB_PID ?= $(DEFAULT_PID)

CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID) -DCONFIG_USB_PID=0x$(USB_PID)

include $(RIOTBASE)/Makefile.include

# Set USB VID/PID via CFLAGS if not being set via Kconfig
ifndef CONFIG_USB_VID
CFLAGS += -DCONFIG_USB_VID=0x$(USB_VID)
else
USB_VID = $(patsubst 0x%,%,$(CONFIG_USB_VID))
endif

ifndef CONFIG_USB_PID
CFLAGS += -DCONFIG_USB_PID=0x$(USB_PID)
else
USB_PID = $(patsubst 0x%,%,$(CONFIG_USB_PID))
endif

# There is a Kconfig in the app folder, we need to indicate not to run it by default
SHOULD_RUN_KCONFIG ?=

.PHONY: usb_id_check
usb_id_check:
@if [ $(USB_VID) = $(DEFAULT_VID) -o $(USB_PID) = $(DEFAULT_PID) ] ; then \
Expand Down