Skip to content

Commit

Permalink
samples: shell_module: add shell support over CDC ACM
Browse files Browse the repository at this point in the history
Add shell support over CDC ACM.

Signed-off-by: Johann Fischer <[email protected]>
  • Loading branch information
jfischer-no committed Feb 25, 2021
1 parent db87ee2 commit 1d43686
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
8 changes: 8 additions & 0 deletions samples/subsys/shell/shell_module/overlay-usb.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr USB console sample"
CONFIG_USB_UART_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
CONFIG_UART_SHELL_ON_DEV_NAME="CDC_ACM_0"
CONFIG_SHELL_BACKEND_SERIAL_INIT_PRIORITY=51
6 changes: 6 additions & 0 deletions samples/subsys/shell/shell_module/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ tests:
tags: shell
harness: keyboard
min_ram: 40
sample.shell.shell_module.usb:
depends_on: usb_device
tags: shell usb
harness: keyboard
min_ram: 40
extra_args: OVERLAY_CONFIG="overlay-usb.conf"
sample.shell.shell_module.minimal:
filter: ( CONFIG_SERIAL and CONFIG_UART_SHELL_ON_DEV_NAME )
tags: shell
Expand Down
15 changes: 15 additions & 0 deletions samples/subsys/shell/shell_module/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <version.h>
#include <logging/log.h>
#include <stdlib.h>
#include <drivers/uart.h>
#include <usb/usb_device.h>

LOG_MODULE_REGISTER(app);

Expand Down Expand Up @@ -145,5 +147,18 @@ SHELL_CMD_ARG_REGISTER(version, NULL, "Show kernel version", cmd_version, 1, 0);

void main(void)
{
#if defined(CONFIG_USB_UART_CONSOLE)
const struct device *dev;
uint32_t dtr = 0;

dev = device_get_binding(CONFIG_UART_SHELL_ON_DEV_NAME);
if (dev == NULL || usb_enable(NULL)) {
return;
}

while (!dtr) {
uart_line_ctrl_get(dev, UART_LINE_CTRL_DTR, &dtr);
k_sleep(K_MSEC(100));
}
#endif
}

0 comments on commit 1d43686

Please sign in to comment.