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

samples: zephyr: subsys: usb: enable hid testing for H20 and L20 #21050

Merged
merged 1 commit into from
Mar 20, 2025
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
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,7 @@
/samples/zephyr/sensor/bme680/ @nrfconnect/ncs-low-level-test
/samples/zephyr/sensor/qdec/ @nrfconnect/ncs-low-level-test
/samples/zephyr/subsys/settings/ @nrfconnect/ncs-low-level-test
/samples/zephyr/subsys/usb/ @nrfconnect/ncs-low-level-test

/samples/**/*.svg @nrfconnect/ncs-doc-leads
/samples/**/*.png @nrfconnect/ncs-doc-leads
Expand Down
14 changes: 14 additions & 0 deletions samples/zephyr/subsys/usb/hid-keyboard/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hid-keyboard)

include(${ZEPHYR_BASE}/samples/subsys/usb/common/common.cmake)
FILE(GLOB app_sources ${ZEPHYR_BASE}/samples/subsys/usb/hid-keyboard/src/*.c)
target_sources(app PRIVATE ${app_sources})
1 change: 1 addition & 0 deletions samples/zephyr/subsys/usb/hid-keyboard/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source "samples/subsys/usb/hid-keyboard/Kconfig"
4 changes: 4 additions & 0 deletions samples/zephyr/subsys/usb/hid-keyboard/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This sample extends the same-named Zephyr sample to verify it
with Nordic development kits.

Source code and basic configuration files can be found in the corresponding folder structure in zephyr/samples/subsys/usb/hid-keyboard.
9 changes: 9 additions & 0 deletions samples/zephyr/subsys/usb/hid-keyboard/app.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/ {
hid_dev_0: hid_dev_0 {
compatible = "zephyr,hid-device";
interface-name = "HID0";
protocol-code = "keyboard";
in-report-size = <64>;
in-polling-period-us = <1000>;
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/ {
hid_dev_0: hid_dev_0 {
compatible = "zephyr,hid-device";
interface-name = "HID0";
in-report-size = <256>;
in-polling-period-us = <1000>;
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "large_in_report.overlay"

/ {
hid_dev_0: hid_dev_0 {
compatible = "zephyr,hid-device";
out-report-size = <128>;
out-polling-period-us = <16000>;
};
};
9 changes: 9 additions & 0 deletions samples/zephyr/subsys/usb/hid-keyboard/out_report.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "app.overlay"

/ {
hid_dev_0: hid_dev_0 {
compatible = "zephyr,hid-device";
out-report-size = <64>;
out-polling-period-us = <16000>;
};
};
14 changes: 14 additions & 0 deletions samples/zephyr/subsys/usb/hid-keyboard/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CONFIG_USB_DEVICE_STACK_NEXT=y
CONFIG_USBD_HID_SUPPORT=y

CONFIG_LOG=y
CONFIG_USBD_LOG_LEVEL_INF=y
CONFIG_USBD_HID_LOG_LEVEL_WRN=y
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
CONFIG_LOG_BUFFER_SIZE=8192

CONFIG_SAMPLE_USBD_PID=0x0007

CONFIG_GPIO=y
CONFIG_INPUT=y
CONFIG_INPUT_MODE_SYNCHRONOUS=y
98 changes: 98 additions & 0 deletions samples/zephyr/subsys/usb/hid-keyboard/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
sample:
name: USB HID keyboard sample
common:
filter: dt_alias_exists("sw0") and dt_alias_exists("led0")
depends_on:
# - usbd
- gpio
tags:
- usb
- ci_samples_zephyr_subsys_usb
timeout: 15
harness: console
harness_config:
type: multi_line
regex:
- "HS bNumConfigurations 1"
- "FS bNumConfigurations 1"
- "HID keyboard sample is initialized"
- "USBD message: VBUS ready"
- "Actual device speed 2"
- "s-in-status finished"
tests:
nrf.extended.sample.usbd.hid-keyboard:
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp
platform_allow:
- nrf54h20dk/nrf54h20/cpuapp
nrf.extended.sample.usbd.hid-keyboard.out-report:
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp
platform_allow:
- nrf54h20dk/nrf54h20/cpuapp
extra_args:
- EXTRA_DTC_OVERLAY_FILE="out_report.overlay"
nrf.extended.sample.usbd.hid-keyboard.large-report:
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp
platform_allow:
- nrf54h20dk/nrf54h20/cpuapp
extra_args:
- EXTRA_DTC_OVERLAY_FILE="large_in_report.overlay"
nrf.extended.sample.usbd.hid-keyboard.large-out-report:
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp
platform_allow:
- nrf54h20dk/nrf54h20/cpuapp
extra_args:
- EXTRA_DTC_OVERLAY_FILE="large_out_report.overlay"
nrf.extended.sample.usbd.hid-keyboard.l20:
integration_platforms:
- nrf54l20pdk/nrf54l20/cpuapp
platform_allow:
- nrf54l20pdk/nrf54l20/cpuapp
harness_config:
type: multi_line
regex:
- "HS bNumConfigurations 1"
- "FS bNumConfigurations 1"
- "HID keyboard sample is initialized"
nrf.extended.sample.usbd.hid-keyboard.out-report.l20:
integration_platforms:
- nrf54l20pdk/nrf54l20/cpuapp
platform_allow:
- nrf54l20pdk/nrf54l20/cpuapp
extra_args:
- EXTRA_DTC_OVERLAY_FILE="out_report.overlay"
harness_config:
type: multi_line
regex:
- "HS bNumConfigurations 1"
- "FS bNumConfigurations 1"
- "HID keyboard sample is initialized"
nrf.extended.sample.usbd.hid-keyboard.large-report.l20:
integration_platforms:
- nrf54l20pdk/nrf54l20/cpuapp
platform_allow:
- nrf54l20pdk/nrf54l20/cpuapp
extra_args:
- EXTRA_DTC_OVERLAY_FILE="large_in_report.overlay"
harness_config:
type: multi_line
regex:
- "HS bNumConfigurations 1"
- "FS bNumConfigurations 1"
- "HID keyboard sample is initialized"
nrf.extended.sample.usbd.hid-keyboard.large-out-report.l20:
integration_platforms:
- nrf54l20pdk/nrf54l20/cpuapp
platform_allow:
- nrf54l20pdk/nrf54l20/cpuapp
extra_args:
- EXTRA_DTC_OVERLAY_FILE="large_out_report.overlay"
harness_config:
type: multi_line
regex:
- "HS bNumConfigurations 1"
- "FS bNumConfigurations 1"
- "HID keyboard sample is initialized"
14 changes: 14 additions & 0 deletions samples/zephyr/subsys/usb/hid-mouse/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(hid-mouse)

include(${ZEPHYR_BASE}/samples/subsys/usb/common/common.cmake)
FILE(GLOB app_sources ${ZEPHYR_BASE}/samples/subsys/usb/hid-mouse/src/*.c)
target_sources(app PRIVATE ${app_sources})
1 change: 1 addition & 0 deletions samples/zephyr/subsys/usb/hid-mouse/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source "samples/subsys/usb/hid-mouse/Kconfig"
4 changes: 4 additions & 0 deletions samples/zephyr/subsys/usb/hid-mouse/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This sample extends the same-named Zephyr sample to verify it
with Nordic development kits.

Source code and basic configuration files can be found in the corresponding folder structure in zephyr/samples/subsys/usb/hid-mouse.
13 changes: 13 additions & 0 deletions samples/zephyr/subsys/usb/hid-mouse/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_HID=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr HID mouse sample"
CONFIG_USB_DEVICE_PID=0x0007
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n

CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y

CONFIG_GPIO=y
CONFIG_INPUT=y
CONFIG_INPUT_MODE_SYNCHRONOUS=y
48 changes: 48 additions & 0 deletions samples/zephyr/subsys/usb/hid-mouse/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
sample:
name: USB HID mouse sample
common:
filter: dt_alias_exists("sw0") and dt_alias_exists("led0")
depends_on:
- gpio
tags:
- ci_samples_zephyr_subsys_usb
- usb

tests:
nrf.extended.sample.usb_device_next.hid-mouse.h20:
depends_on:
- usbd
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp
platform_allow:
- nrf54h20dk/nrf54h20/cpuapp
extra_args:
- CONF_FILE="usbd_next_prj.conf"
- EXTRA_DTC_OVERLAY_FILE="usbd_next.overlay"
timeout: 15
harness: console
harness_config:
type: multi_line
regex:
- "HS bNumConfigurations 1"
- "FS bNumConfigurations 1"
- "Actual device speed 2"
- "s-in-status finished"
nrf.extended.sample.usb_device_next.hid-mouse.l20:
# depends_on:
# - usbd
integration_platforms:
- nrf54l20pdk/nrf54l20/cpuapp
platform_allow:
- nrf54l20pdk/nrf54l20/cpuapp
extra_args:
- CONF_FILE="usbd_next_prj.conf"
- EXTRA_DTC_OVERLAY_FILE="usbd_next.overlay"
timeout: 15
harness: console
harness_config:
type: multi_line
regex:
- "HS bNumConfigurations 1"
- "FS bNumConfigurations 1"
- "Actual device speed 2"
9 changes: 9 additions & 0 deletions samples/zephyr/subsys/usb/hid-mouse/usbd_next.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/ {
hid_dev_0: hid_dev_0 {
compatible = "zephyr,hid-device";
interface-name = "HID0";
protocol-code = "none";
in-polling-period-us = <1000>;
in-report-size = <64>;
};
};
12 changes: 12 additions & 0 deletions samples/zephyr/subsys/usb/hid-mouse/usbd_next_prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CONFIG_USB_DEVICE_STACK_NEXT=y
CONFIG_USBD_HID_SUPPORT=y

CONFIG_LOG=y
CONFIG_USBD_LOG_LEVEL_INF=y
CONFIG_USBD_HID_LOG_LEVEL_WRN=y
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
CONFIG_LOG_BUFFER_SIZE=8192
CONFIG_SAMPLE_USBD_PID=0x0007

CONFIG_GPIO=y
CONFIG_INPUT=y
5 changes: 5 additions & 0 deletions scripts/ci/tags.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1614,3 +1614,8 @@ ci_samples_zephyr_drivers_adc:
files:
- nrf/samples/zephyr/drivers/adc/
- zephyr/samples/drivers/adc/

ci_samples_zephyr_subsys_usb:
files:
- nrf/samples/zephyr/subsys/usb/
- zephyr/samples/subsys/usb/
10 changes: 10 additions & 0 deletions scripts/quarantine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,13 @@
platforms:
- nrf54l20pdk/nrf54l20/cpuapp
comment: "https://nordicsemi.atlassian.net/browse/NRFX-7205"

- scenarios:
- nrf.extended.sample.usb_device_next.hid-mouse.l20
- nrf.extended.sample.usbd.hid-keyboard.l20
- nrf.extended.sample.usbd.hid-keyboard.out-report.l20
- nrf.extended.sample.usbd.hid-keyboard.large-report.l20
- nrf.extended.sample.usbd.hid-keyboard.large-out-report.l20
platforms:
- nrf54l20pdk/nrf54l20/cpuapp
comment: "https://nordicsemi.atlassian.net/browse/NRFX-7255"