Skip to content

Commit 73c2240

Browse files
nordic-piksPerMac
authored andcommitted
samples: zephyr: subsys: usb: enable hid testing for H20 and L20
Based on zephyr. Signed-off-by: Piotr Kosycarz <piotr.kosycarz@nordicsemi.no>
1 parent 50ae83e commit 73c2240

19 files changed

+283
-0
lines changed

CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@
677677
/samples/zephyr/sensor/bme680/ @nrfconnect/ncs-low-level-test
678678
/samples/zephyr/sensor/qdec/ @nrfconnect/ncs-low-level-test
679679
/samples/zephyr/subsys/settings/ @nrfconnect/ncs-low-level-test
680+
/samples/zephyr/subsys/usb/ @nrfconnect/ncs-low-level-test
680681

681682
/samples/**/*.svg @nrfconnect/ncs-doc-leads
682683
/samples/**/*.png @nrfconnect/ncs-doc-leads
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(hid-keyboard)
11+
12+
include(${ZEPHYR_BASE}/samples/subsys/usb/common/common.cmake)
13+
FILE(GLOB app_sources ${ZEPHYR_BASE}/samples/subsys/usb/hid-keyboard/src/*.c)
14+
target_sources(app PRIVATE ${app_sources})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
source "samples/subsys/usb/hid-keyboard/Kconfig"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This sample extends the same-named Zephyr sample to verify it
2+
with Nordic development kits.
3+
4+
Source code and basic configuration files can be found in the corresponding folder structure in zephyr/samples/subsys/usb/hid-keyboard.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/ {
2+
hid_dev_0: hid_dev_0 {
3+
compatible = "zephyr,hid-device";
4+
interface-name = "HID0";
5+
protocol-code = "keyboard";
6+
in-report-size = <64>;
7+
in-polling-period-us = <1000>;
8+
};
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/ {
2+
hid_dev_0: hid_dev_0 {
3+
compatible = "zephyr,hid-device";
4+
interface-name = "HID0";
5+
in-report-size = <256>;
6+
in-polling-period-us = <1000>;
7+
};
8+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "large_in_report.overlay"
2+
3+
/ {
4+
hid_dev_0: hid_dev_0 {
5+
compatible = "zephyr,hid-device";
6+
out-report-size = <128>;
7+
out-polling-period-us = <16000>;
8+
};
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "app.overlay"
2+
3+
/ {
4+
hid_dev_0: hid_dev_0 {
5+
compatible = "zephyr,hid-device";
6+
out-report-size = <64>;
7+
out-polling-period-us = <16000>;
8+
};
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CONFIG_USB_DEVICE_STACK_NEXT=y
2+
CONFIG_USBD_HID_SUPPORT=y
3+
4+
CONFIG_LOG=y
5+
CONFIG_USBD_LOG_LEVEL_INF=y
6+
CONFIG_USBD_HID_LOG_LEVEL_WRN=y
7+
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
8+
CONFIG_LOG_BUFFER_SIZE=8192
9+
10+
CONFIG_SAMPLE_USBD_PID=0x0007
11+
12+
CONFIG_GPIO=y
13+
CONFIG_INPUT=y
14+
CONFIG_INPUT_MODE_SYNCHRONOUS=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
sample:
2+
name: USB HID keyboard sample
3+
common:
4+
filter: dt_alias_exists("sw0") and dt_alias_exists("led0")
5+
depends_on:
6+
# - usbd
7+
- gpio
8+
tags:
9+
- usb
10+
- ci_samples_zephyr_subsys_usb
11+
timeout: 15
12+
harness: console
13+
harness_config:
14+
type: multi_line
15+
regex:
16+
- "HS bNumConfigurations 1"
17+
- "FS bNumConfigurations 1"
18+
- "HID keyboard sample is initialized"
19+
- "USBD message: VBUS ready"
20+
- "Actual device speed 2"
21+
- "s-in-status finished"
22+
tests:
23+
nrf.extended.sample.usbd.hid-keyboard:
24+
integration_platforms:
25+
- nrf54h20dk/nrf54h20/cpuapp
26+
platform_allow:
27+
- nrf54h20dk/nrf54h20/cpuapp
28+
nrf.extended.sample.usbd.hid-keyboard.out-report:
29+
integration_platforms:
30+
- nrf54h20dk/nrf54h20/cpuapp
31+
platform_allow:
32+
- nrf54h20dk/nrf54h20/cpuapp
33+
extra_args:
34+
- EXTRA_DTC_OVERLAY_FILE="out_report.overlay"
35+
nrf.extended.sample.usbd.hid-keyboard.large-report:
36+
integration_platforms:
37+
- nrf54h20dk/nrf54h20/cpuapp
38+
platform_allow:
39+
- nrf54h20dk/nrf54h20/cpuapp
40+
extra_args:
41+
- EXTRA_DTC_OVERLAY_FILE="large_in_report.overlay"
42+
nrf.extended.sample.usbd.hid-keyboard.large-out-report:
43+
integration_platforms:
44+
- nrf54h20dk/nrf54h20/cpuapp
45+
platform_allow:
46+
- nrf54h20dk/nrf54h20/cpuapp
47+
extra_args:
48+
- EXTRA_DTC_OVERLAY_FILE="large_out_report.overlay"
49+
nrf.extended.sample.usbd.hid-keyboard.l20:
50+
integration_platforms:
51+
- nrf54l20pdk/nrf54l20/cpuapp
52+
platform_allow:
53+
- nrf54l20pdk/nrf54l20/cpuapp
54+
harness_config:
55+
type: multi_line
56+
regex:
57+
- "HS bNumConfigurations 1"
58+
- "FS bNumConfigurations 1"
59+
- "HID keyboard sample is initialized"
60+
nrf.extended.sample.usbd.hid-keyboard.out-report.l20:
61+
integration_platforms:
62+
- nrf54l20pdk/nrf54l20/cpuapp
63+
platform_allow:
64+
- nrf54l20pdk/nrf54l20/cpuapp
65+
extra_args:
66+
- EXTRA_DTC_OVERLAY_FILE="out_report.overlay"
67+
harness_config:
68+
type: multi_line
69+
regex:
70+
- "HS bNumConfigurations 1"
71+
- "FS bNumConfigurations 1"
72+
- "HID keyboard sample is initialized"
73+
nrf.extended.sample.usbd.hid-keyboard.large-report.l20:
74+
integration_platforms:
75+
- nrf54l20pdk/nrf54l20/cpuapp
76+
platform_allow:
77+
- nrf54l20pdk/nrf54l20/cpuapp
78+
extra_args:
79+
- EXTRA_DTC_OVERLAY_FILE="large_in_report.overlay"
80+
harness_config:
81+
type: multi_line
82+
regex:
83+
- "HS bNumConfigurations 1"
84+
- "FS bNumConfigurations 1"
85+
- "HID keyboard sample is initialized"
86+
nrf.extended.sample.usbd.hid-keyboard.large-out-report.l20:
87+
integration_platforms:
88+
- nrf54l20pdk/nrf54l20/cpuapp
89+
platform_allow:
90+
- nrf54l20pdk/nrf54l20/cpuapp
91+
extra_args:
92+
- EXTRA_DTC_OVERLAY_FILE="large_out_report.overlay"
93+
harness_config:
94+
type: multi_line
95+
regex:
96+
- "HS bNumConfigurations 1"
97+
- "FS bNumConfigurations 1"
98+
- "HID keyboard sample is initialized"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(hid-mouse)
11+
12+
include(${ZEPHYR_BASE}/samples/subsys/usb/common/common.cmake)
13+
FILE(GLOB app_sources ${ZEPHYR_BASE}/samples/subsys/usb/hid-mouse/src/*.c)
14+
target_sources(app PRIVATE ${app_sources})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
source "samples/subsys/usb/hid-mouse/Kconfig"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This sample extends the same-named Zephyr sample to verify it
2+
with Nordic development kits.
3+
4+
Source code and basic configuration files can be found in the corresponding folder structure in zephyr/samples/subsys/usb/hid-mouse.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CONFIG_USB_DEVICE_STACK=y
2+
CONFIG_USB_DEVICE_HID=y
3+
CONFIG_USB_DEVICE_PRODUCT="Zephyr HID mouse sample"
4+
CONFIG_USB_DEVICE_PID=0x0007
5+
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
6+
7+
CONFIG_LOG=y
8+
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
9+
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
10+
11+
CONFIG_GPIO=y
12+
CONFIG_INPUT=y
13+
CONFIG_INPUT_MODE_SYNCHRONOUS=y
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
sample:
2+
name: USB HID mouse sample
3+
common:
4+
filter: dt_alias_exists("sw0") and dt_alias_exists("led0")
5+
depends_on:
6+
- gpio
7+
tags:
8+
- ci_samples_zephyr_subsys_usb
9+
- usb
10+
11+
tests:
12+
nrf.extended.sample.usb_device_next.hid-mouse.h20:
13+
depends_on:
14+
- usbd
15+
integration_platforms:
16+
- nrf54h20dk/nrf54h20/cpuapp
17+
platform_allow:
18+
- nrf54h20dk/nrf54h20/cpuapp
19+
extra_args:
20+
- CONF_FILE="usbd_next_prj.conf"
21+
- EXTRA_DTC_OVERLAY_FILE="usbd_next.overlay"
22+
timeout: 15
23+
harness: console
24+
harness_config:
25+
type: multi_line
26+
regex:
27+
- "HS bNumConfigurations 1"
28+
- "FS bNumConfigurations 1"
29+
- "Actual device speed 2"
30+
- "s-in-status finished"
31+
nrf.extended.sample.usb_device_next.hid-mouse.l20:
32+
# depends_on:
33+
# - usbd
34+
integration_platforms:
35+
- nrf54l20pdk/nrf54l20/cpuapp
36+
platform_allow:
37+
- nrf54l20pdk/nrf54l20/cpuapp
38+
extra_args:
39+
- CONF_FILE="usbd_next_prj.conf"
40+
- EXTRA_DTC_OVERLAY_FILE="usbd_next.overlay"
41+
timeout: 15
42+
harness: console
43+
harness_config:
44+
type: multi_line
45+
regex:
46+
- "HS bNumConfigurations 1"
47+
- "FS bNumConfigurations 1"
48+
- "Actual device speed 2"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/ {
2+
hid_dev_0: hid_dev_0 {
3+
compatible = "zephyr,hid-device";
4+
interface-name = "HID0";
5+
protocol-code = "none";
6+
in-polling-period-us = <1000>;
7+
in-report-size = <64>;
8+
};
9+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CONFIG_USB_DEVICE_STACK_NEXT=y
2+
CONFIG_USBD_HID_SUPPORT=y
3+
4+
CONFIG_LOG=y
5+
CONFIG_USBD_LOG_LEVEL_INF=y
6+
CONFIG_USBD_HID_LOG_LEVEL_WRN=y
7+
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
8+
CONFIG_LOG_BUFFER_SIZE=8192
9+
CONFIG_SAMPLE_USBD_PID=0x0007
10+
11+
CONFIG_GPIO=y
12+
CONFIG_INPUT=y

scripts/ci/tags.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -1614,3 +1614,8 @@ ci_samples_zephyr_drivers_adc:
16141614
files:
16151615
- nrf/samples/zephyr/drivers/adc/
16161616
- zephyr/samples/drivers/adc/
1617+
1618+
ci_samples_zephyr_subsys_usb:
1619+
files:
1620+
- nrf/samples/zephyr/subsys/usb/
1621+
- zephyr/samples/subsys/usb/

scripts/quarantine.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,13 @@
4949
platforms:
5050
- nrf54l20pdk/nrf54l20/cpuapp
5151
comment: "https://nordicsemi.atlassian.net/browse/NRFX-7205"
52+
53+
- scenarios:
54+
- nrf.extended.sample.usb_device_next.hid-mouse.l20
55+
- nrf.extended.sample.usbd.hid-keyboard.l20
56+
- nrf.extended.sample.usbd.hid-keyboard.out-report.l20
57+
- nrf.extended.sample.usbd.hid-keyboard.large-report.l20
58+
- nrf.extended.sample.usbd.hid-keyboard.large-out-report.l20
59+
platforms:
60+
- nrf54l20pdk/nrf54l20/cpuapp
61+
comment: "https://nordicsemi.atlassian.net/browse/NRFX-7255"

0 commit comments

Comments
 (0)