snippets: add cdc-acm-console
This snippet is based on samples/subsys/usb/console. Since it's a
snippet, it can be used in any application as long as its requirements
are met. This makes it more general purpose.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
diff --git a/snippets/cdc-acm-console/README.rst b/snippets/cdc-acm-console/README.rst
new file mode 100644
index 0000000..c1d165b
--- /dev/null
+++ b/snippets/cdc-acm-console/README.rst
@@ -0,0 +1,36 @@
+.. _snippet-cdc-acm-console:
+
+CDC-ACM Console Snippet (cdc-acm-console)
+#########################################
+
+.. code-block:: console
+
+ west build -S cdc-acm-console [...]
+
+Overview
+********
+
+This snippet redirects serial console output to a CDC ACM UART. The USB device
+which should be used is configured using :ref:`devicetree`.
+
+Requirements
+************
+
+Hardware support for:
+
+- :kconfig:option:`CONFIG_USB_DEVICE_STACK`
+- :kconfig:option:`CONFIG_SERIAL`
+- :kconfig:option:`CONFIG_CONSOLE`
+- :kconfig:option:`CONFIG_UART_CONSOLE`
+- :kconfig:option:`CONFIG_UART_LINE_CTRL`
+
+A devicetree node with node label ``zephyr_udc0`` that points to an enabled USB
+device node with driver support. This should look roughly like this in
+:ref:`your devicetree <get-devicetree-outputs>`:
+
+.. code-block:: DTS
+
+ zephyr_udc0: usbd@deadbeef {
+ compatible = "vnd,usb-device";
+ /* ... */
+ };
diff --git a/snippets/cdc-acm-console/cdc-acm-console.conf b/snippets/cdc-acm-console/cdc-acm-console.conf
new file mode 100644
index 0000000..2810341
--- /dev/null
+++ b/snippets/cdc-acm-console/cdc-acm-console.conf
@@ -0,0 +1,8 @@
+CONFIG_USB_DEVICE_STACK=y
+CONFIG_USB_DEVICE_PRODUCT="Zephyr USB console sample"
+CONFIG_USB_DEVICE_PID=0x0004
+
+CONFIG_SERIAL=y
+CONFIG_CONSOLE=y
+CONFIG_UART_CONSOLE=y
+CONFIG_UART_LINE_CTRL=y
diff --git a/snippets/cdc-acm-console/cdc-acm-console.overlay b/snippets/cdc-acm-console/cdc-acm-console.overlay
new file mode 100644
index 0000000..91e6188
--- /dev/null
+++ b/snippets/cdc-acm-console/cdc-acm-console.overlay
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2021, 2023 Nordic Semiconductor ASA
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+/ {
+ chosen {
+ zephyr,console = &snippet_cdc_acm_console_uart;
+ };
+};
+
+&zephyr_udc0 {
+ snippet_cdc_acm_console_uart: snippet_cdc_acm_console_uart {
+ compatible = "zephyr,cdc-acm-uart";
+ };
+};
diff --git a/snippets/cdc-acm-console/snippet.yml b/snippets/cdc-acm-console/snippet.yml
new file mode 100644
index 0000000..eab58a3
--- /dev/null
+++ b/snippets/cdc-acm-console/snippet.yml
@@ -0,0 +1,4 @@
+name: cdc-acm-console
+append:
+ OVERLAY_CONFIG: cdc-acm-console.conf
+ DTC_OVERLAY_FILE: cdc-acm-console.overlay