diff --git a/doc/connectivity/usb/device/usb_device.rst b/doc/connectivity/usb/device/usb_device.rst index 05ec4145c3e..67e1d1b77fe 100644 --- a/doc/connectivity/usb/device/usb_device.rst +++ b/doc/connectivity/usb/device/usb_device.rst @@ -577,7 +577,7 @@ The following Product IDs are currently used: +====================================================+========+ | :zephyr:code-sample:`usb-cdc-acm` | 0x0001 | +----------------------------------------------------+--------+ -| :zephyr:code-sample:`usb-cdc-acm-composite` | 0x0002 | +| Reserved (previously: usb-cdc-acm-composite) | 0x0002 | +----------------------------------------------------+--------+ | Reserved (previously: usb-hid-cdc) | 0x0003 | +----------------------------------------------------+--------+ diff --git a/samples/subsys/usb/cdc_acm_composite/CMakeLists.txt b/samples/subsys/usb/cdc_acm_composite/CMakeLists.txt deleted file mode 100644 index 0cba7b39068..00000000000 --- a/samples/subsys/usb/cdc_acm_composite/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 - -cmake_minimum_required(VERSION 3.20.0) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(cdc_acm) - -FILE(GLOB app_sources src/*.c) -target_sources(app PRIVATE ${app_sources}) diff --git a/samples/subsys/usb/cdc_acm_composite/README.rst b/samples/subsys/usb/cdc_acm_composite/README.rst deleted file mode 100644 index 090785ecd3f..00000000000 --- a/samples/subsys/usb/cdc_acm_composite/README.rst +++ /dev/null @@ -1,64 +0,0 @@ -.. zephyr:code-sample:: usb-cdc-acm-composite - :name: USB CDC-ACM composite - :relevant-api: _usb_device_core_api - - Implement a composite USB device exposing two serial ports using USB CDC-ACM driver. - -Overview -******** - -This sample app demonstrates use of a USB Communication Device Class (CDC) -Abstract Control Model (ACM) driver provided by the Zephyr project in -Composite configuration. - -Two serial ports are created when the device is plugged to the PC. -Received data from one serial port is sent to another serial port -provided by this driver. - -Running -******* - -Plug the board into a host device, for example, a PC running Linux. -The board will be detected as shown by the Linux dmesg command: - -.. code-block:: console - - usb 1-1.5.4: new full-speed USB device number 28 using ehci-pci - usb 1-1.5.4: New USB device found, idVendor=2fe3, idProduct=0002, bcdDevice= 2.03 - usb 1-1.5.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3 - usb 1-1.5.4: Product: Zephyr CDC ACM Composite sample - usb 1-1.5.4: Manufacturer: ZEPHYR - usb 1-1.5.4: SerialNumber: 86FE679A598AC47A - cdc_acm 1-1.5.4:1.0: ttyACM1: USB ACM device - cdc_acm 1-1.5.4:1.2: ttyACM2: USB ACM device - -The app prints on serial output, used for the console: - -.. code-block:: console - - Wait for DTR - -Open a serial port emulator, for example, minicom, -and attach it to both detected CDC ACM devices: - -.. code-block:: console - - minicom --device /dev/ttyACM1 - minicom --device /dev/ttyACM2 - -The app should respond on serial output with: - -.. code-block:: console - - DTR set, start test - Baudrate detected: 115200 - Baudrate detected: 115200 - -And on ttyACM devices provided by the Zephyr USB device stack: - -.. code-block:: console - - Send characters to another UART device - -The characters entered in one serial port will be sent to another -serial port. diff --git a/samples/subsys/usb/cdc_acm_composite/app.overlay b/samples/subsys/usb/cdc_acm_composite/app.overlay deleted file mode 100644 index dc6bcf2f105..00000000000 --- a/samples/subsys/usb/cdc_acm_composite/app.overlay +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2021 Nordic Semiconductor ASA - * - * SPDX-License-Identifier: Apache-2.0 - */ - -&zephyr_udc0 { - cdc_acm_uart0 { - compatible = "zephyr,cdc-acm-uart"; - }; - - cdc_acm_uart1 { - compatible = "zephyr,cdc-acm-uart"; - }; -}; diff --git a/samples/subsys/usb/cdc_acm_composite/prj.conf b/samples/subsys/usb/cdc_acm_composite/prj.conf deleted file mode 100644 index db41a5ba64d..00000000000 --- a/samples/subsys/usb/cdc_acm_composite/prj.conf +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG_STDOUT_CONSOLE=y -CONFIG_LOG=y -CONFIG_SERIAL=y -CONFIG_UART_INTERRUPT_DRIVEN=y -CONFIG_UART_LINE_CTRL=y - -CONFIG_USB_DEVICE_STACK=y -CONFIG_USB_DEVICE_PRODUCT="Zephyr CDC ACM Composite sample" -CONFIG_USB_DEVICE_PID=0x0002 -CONFIG_USB_CDC_ACM_RINGBUF_SIZE=512 -CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n - -CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y -CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y diff --git a/samples/subsys/usb/cdc_acm_composite/sample.yaml b/samples/subsys/usb/cdc_acm_composite/sample.yaml deleted file mode 100644 index efaedd86852..00000000000 --- a/samples/subsys/usb/cdc_acm_composite/sample.yaml +++ /dev/null @@ -1,17 +0,0 @@ -sample: - description: Application with two CDC ACM instances requires at least - two OUT and four IN endpoints on the USB device controller. - name: CDC ACM Composite USB -tests: - sample.usb.cdc-acm-composite: - depends_on: usb_device - tags: usb - platform_exclude: - - nucleo_f429zi - - nucleo_f207zg - arch_exclude: posix - harness: console - harness_config: - type: one_line - regex: - - "Wait for DTR" diff --git a/samples/subsys/usb/cdc_acm_composite/src/main.c b/samples/subsys/usb/cdc_acm_composite/src/main.c deleted file mode 100644 index adf1c4911d6..00000000000 --- a/samples/subsys/usb/cdc_acm_composite/src/main.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2016 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -/** - * @file - * @brief Sample app for CDC ACM class driver - * - * Sample app for USB CDC ACM class driver. The received data is echoed back - * to the serial port. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -LOG_MODULE_REGISTER(cdc_acm_composite, LOG_LEVEL_INF); - -#define RING_BUF_SIZE (64 * 2) - -uint8_t buffer0[RING_BUF_SIZE]; -uint8_t buffer1[RING_BUF_SIZE]; - -struct serial_peer { - const struct device *dev; - struct serial_peer *data; - struct ring_buf rb; -}; - -#define DEFINE_SERIAL_PEER(node_id) { .dev = DEVICE_DT_GET(node_id), }, -static struct serial_peer peers[] = { - DT_FOREACH_STATUS_OKAY(zephyr_cdc_acm_uart, DEFINE_SERIAL_PEER) -}; - -BUILD_ASSERT(ARRAY_SIZE(peers) >= 2, "Not enough CDC ACM instances"); - -static void interrupt_handler(const struct device *dev, void *user_data) -{ - struct serial_peer *peer = user_data; - - while (uart_irq_update(dev) && uart_irq_is_pending(dev)) { - LOG_DBG("dev %p peer %p", dev, peer); - - if (uart_irq_rx_ready(dev)) { - uint8_t buf[64]; - int read; - size_t wrote; - struct ring_buf *rb = &peer->data->rb; - - read = uart_fifo_read(dev, buf, sizeof(buf)); - if (read < 0) { - LOG_ERR("Failed to read UART FIFO"); - read = 0; - }; - - wrote = ring_buf_put(rb, buf, read); - if (wrote < read) { - LOG_ERR("Drop %zu bytes", read - wrote); - } - - LOG_DBG("dev %p -> dev %p send %zu bytes", - dev, peer->dev, wrote); - if (wrote) { - uart_irq_tx_enable(peer->dev); - } - } - - if (uart_irq_tx_ready(dev)) { - uint8_t buf[64]; - size_t wrote, len; - - len = ring_buf_get(&peer->rb, buf, sizeof(buf)); - if (!len) { - LOG_DBG("dev %p TX buffer empty", dev); - uart_irq_tx_disable(dev); - } else { - wrote = uart_fifo_fill(dev, buf, len); - LOG_DBG("dev %p wrote len %zu", dev, wrote); - } - } - } -} - -static void uart_line_set(const struct device *dev) -{ - uint32_t baudrate; - int ret; - - /* They are optional, we use them to test the interrupt endpoint */ - ret = uart_line_ctrl_set(dev, UART_LINE_CTRL_DCD, 1); - if (ret) { - LOG_DBG("Failed to set DCD, ret code %d", ret); - } - - ret = uart_line_ctrl_set(dev, UART_LINE_CTRL_DSR, 1); - if (ret) { - LOG_DBG("Failed to set DSR, ret code %d", ret); - } - - /* Wait 1 sec for the host to do all settings */ - k_busy_wait(1000000); - - ret = uart_line_ctrl_get(dev, UART_LINE_CTRL_BAUD_RATE, &baudrate); - if (ret) { - LOG_DBG("Failed to get baudrate, ret code %d", ret); - } else { - LOG_DBG("Baudrate detected: %d", baudrate); - } -} - -int main(void) -{ - uint32_t dtr = 0U; - int ret; - - for (int idx = 0; idx < ARRAY_SIZE(peers); idx++) { - if (!device_is_ready(peers[idx].dev)) { - LOG_ERR("CDC ACM device %s is not ready", - peers[idx].dev->name); - return 0; - } - } - - ret = usb_enable(NULL); - if (ret != 0) { - LOG_ERR("Failed to enable USB"); - return 0; - } - - LOG_INF("Wait for DTR"); - - while (1) { - uart_line_ctrl_get(peers[0].dev, UART_LINE_CTRL_DTR, &dtr); - if (dtr) { - break; - } - - k_sleep(K_MSEC(100)); - } - - while (1) { - uart_line_ctrl_get(peers[1].dev, UART_LINE_CTRL_DTR, &dtr); - if (dtr) { - break; - } - - k_sleep(K_MSEC(100)); - } - - LOG_INF("DTR set, start test"); - - uart_line_set(peers[0].dev); - uart_line_set(peers[1].dev); - - peers[0].data = &peers[1]; - peers[1].data = &peers[0]; - - ring_buf_init(&peers[0].rb, sizeof(buffer0), buffer0); - ring_buf_init(&peers[1].rb, sizeof(buffer1), buffer1); - - uart_irq_callback_user_data_set(peers[1].dev, interrupt_handler, &peers[0]); - uart_irq_callback_user_data_set(peers[0].dev, interrupt_handler, &peers[1]); - - /* Enable rx interrupts */ - uart_irq_rx_enable(peers[0].dev); - uart_irq_rx_enable(peers[1].dev); - return 0; -}