Skip to content

Nrfx 7936 enable usb testing on nrf54lm20dk #3082

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ supported:
- i2s
- pwm
- spi
- usbd
- watchdog
6 changes: 3 additions & 3 deletions samples/subsys/usb/cdc_acm/README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. zephyr:code-sample:: usb-cdc-acm
:name: USB CDC-ACM
:relevant-api: usbd_api _usb_device_core_api uart_interface
:name: USB CDC ACM UART sample
:relevant-api: usbd_api uart_interface

Use USB CDC-ACM driver to implement a serial port echo.
Use USB CDC ACM UART driver to implement a serial port echo.

Overview
********
Expand Down
19 changes: 11 additions & 8 deletions samples/subsys/usb/cdc_acm/prj.conf
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
CONFIG_USB_DEVICE_STACK_NEXT=y

CONFIG_STDOUT_CONSOLE=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr CDC ACM sample"
CONFIG_USB_DEVICE_PID=0x0001
CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
CONFIG_USBD_CDC_ACM_CLASS=y

CONFIG_LOG=y
CONFIG_USBD_LOG_LEVEL_ERR=y
CONFIG_UDC_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USBD_CDC_ACM_LOG_LEVEL_ERR=y

CONFIG_SAMPLE_USBD_PID=0x0001
CONFIG_SAMPLE_USBD_PRODUCT="USBD CDC ACM sample"
19 changes: 1 addition & 18 deletions samples/subsys/usb/cdc_acm/sample.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
sample:
name: CDC ACM USB
tests:
sample.usb.cdc-acm:
depends_on: usb_device
tags: usb
arch_exclude: posix
harness: console
harness_config:
type: one_line
regex:
- "Wait for DTR"
sample.usb_device_next.cdc-acm:
depends_on: usbd
tags: usb
extra_args: CONF_FILE="usbd_next_prj.conf"
integration_platforms:
- nrf52840dk/nrf52840
- nrf54h20dk/nrf54h20/cpuapp
- nrf54lm20dk/nrf54lm20a/cpuapp
- frdm_k64f
- stm32f723e_disco
- nucleo_f413zh
Expand All @@ -34,7 +25,6 @@ tests:
depends_on: usbd
tags: usb
extra_args:
- CONF_FILE="usbd_next_prj.conf"
- DCONFIG_USBD_CDC_ACM_WORKQUEUE=y
integration_platforms:
- frdm_k64f
Expand All @@ -43,10 +33,3 @@ tests:
type: one_line
regex:
- "Wait for DTR"
sample.usb.cdc-acm.buildonly:
depends_on: usb_device
tags: usb
arch_allow: posix
build_only: true
integration_platforms:
- native_sim
40 changes: 2 additions & 38 deletions samples/subsys/usb/cdc_acm/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @file
* @brief Sample echo app for CDC ACM class
*
* Sample app for USB CDC ACM class driver. The received data is echoed back
* to the serial port.
*/

#include <sample_usbd.h>

#include <stdio.h>
Expand All @@ -21,7 +13,6 @@
#include <zephyr/kernel.h>
#include <zephyr/sys/ring_buffer.h>

#include <zephyr/usb/usb_device.h>
#include <zephyr/usb/usbd.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(cdc_acm_echo, LOG_LEVEL_INF);
Expand All @@ -48,7 +39,6 @@ static inline void print_baudrate(const struct device *dev)
}
}

#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
static struct usbd_context *sample_usbd;
K_SEM_DEFINE(dtr_sem, 0, 1);

Expand Down Expand Up @@ -106,7 +96,6 @@ static int enable_usb_device_next(void)

return 0;
}
#endif /* defined(CONFIG_USB_DEVICE_STACK_NEXT) */

static void interrupt_handler(const struct device *dev, void *user_data)
{
Expand Down Expand Up @@ -178,37 +167,16 @@ int main(void)
return 0;
}

#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
ret = enable_usb_device_next();
#else
ret = usb_enable(NULL);
#endif

ret = enable_usb_device_next();
if (ret != 0) {
LOG_ERR("Failed to enable USB");
LOG_ERR("Failed to enable USB device support");
return 0;
}

ring_buf_init(&ringbuf, sizeof(ring_buffer), ring_buffer);

LOG_INF("Wait for DTR");

#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
k_sem_take(&dtr_sem, K_FOREVER);
#else
while (true) {
uint32_t dtr = 0U;

uart_line_ctrl_get(uart_dev, UART_LINE_CTRL_DTR, &dtr);
if (dtr) {
break;
} else {
/* Give CPU resources to low priority threads. */
k_sleep(K_MSEC(100));
}
}
#endif

LOG_INF("DTR set");

/* They are optional, we use them to test the interrupt endpoint */
Expand All @@ -225,11 +193,7 @@ int main(void)
/* Wait 100ms for the host to do all settings */
k_msleep(100);

#ifndef CONFIG_USB_DEVICE_STACK_NEXT
print_baudrate(uart_dev);
#endif
uart_irq_callback_set(uart_dev, interrupt_handler);

/* Enable rx interrupts */
uart_irq_rx_enable(uart_dev);

Expand Down
14 changes: 0 additions & 14 deletions samples/subsys/usb/cdc_acm/usbd_next_prj.conf

This file was deleted.

15 changes: 9 additions & 6 deletions samples/subsys/usb/hid-keyboard/sample.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
sample:
name: USB HID keyboard sample
common:
harness: button
filter: dt_alias_exists("sw0") and dt_alias_exists("led0")
depends_on:
- usbd
- gpio
tags: usb
timeout: 15
harness: console
harness_config:
type: one_line
regex:
- "HID keyboard sample is initialized"
integration_platforms:
- nrf52840dk/nrf52840
- nrf54h20dk/nrf54h20/cpuapp
- nrf54lm20dk/nrf54lm20a/cpuapp
- frdm_k64f
- stm32f723e_disco
- nucleo_f413zh
Expand All @@ -17,17 +24,13 @@ common:
- samd21_xpro
- same54_xpro
tests:
sample.usbd.hid-keyboard:
tags: usb
sample.usbd.hid-keyboard: {}
sample.usbd.hid-keyboard.out-report:
tags: usb
extra_args:
- EXTRA_DTC_OVERLAY_FILE="out_report.overlay"
sample.usbd.hid-keyboard.large-report:
tags: usb
extra_args:
- EXTRA_DTC_OVERLAY_FILE="large_in_report.overlay"
sample.usbd.hid-keyboard.large-out-report:
tags: usb
extra_args:
- EXTRA_DTC_OVERLAY_FILE="large_out_report.overlay"
2 changes: 1 addition & 1 deletion samples/subsys/usb/hid-mouse/README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. zephyr:code-sample:: usb-hid-mouse
:name: USB HID mouse
:relevant-api: _usb_device_core_api usb_hid_device_api input_interface
:relevant-api: usbd_api usbd_hid_device input_interface

Implement a basic HID mouse device.

Expand Down
14 changes: 6 additions & 8 deletions samples/subsys/usb/hid-mouse/prj.conf
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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_USB_DEVICE_STACK_NEXT=y
CONFIG_USBD_HID_SUPPORT=y

CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_USBD_LOG_LEVEL_INF=y
CONFIG_USBD_HID_LOG_LEVEL_WRN=y
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
CONFIG_SAMPLE_USBD_PID=0x0007

CONFIG_GPIO=y
CONFIG_INPUT=y
CONFIG_INPUT_MODE_SYNCHRONOUS=y
19 changes: 9 additions & 10 deletions samples/subsys/usb/hid-mouse/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ common:
filter: dt_alias_exists("sw0") and dt_alias_exists("led0")
depends_on:
- gpio
tags: usb
tests:
sample.usb.hid-mouse:
depends_on:
- usb_device
platform_exclude:
- frdm_mcxn947/mcxn947/cpu0
tags: usb
sample.usb_device_next.hid-mouse:
depends_on:
- usbd
timeout: 15
harness: console
harness_config:
type: multi_line
regex:
- "HS bNumConfigurations 1"
- "FS bNumConfigurations 1"
integration_platforms:
- nrf52840dk/nrf52840
- nrf54h20dk/nrf54h20/cpuapp
- nrf54lm20dk/nrf54lm20a/cpuapp
- frdm_k64f
- stm32f723e_disco
- nucleo_f413zh
- mimxrt1060_evk/mimxrt1062/qspi
- max32690evkit/max32690/m4
extra_args:
- CONF_FILE="usbd_next_prj.conf"
- EXTRA_DTC_OVERLAY_FILE="usbd_next.overlay"
tags: usb
Loading
Loading