diff --git a/examples/nxscope/Kconfig b/examples/nxscope/Kconfig index 94e39b3bd..17f3b5a92 100644 --- a/examples/nxscope/Kconfig +++ b/examples/nxscope/Kconfig @@ -34,6 +34,11 @@ config EXAMPLES_NXSCOPE_SERIAL_BAUD int "nxscope serial baud" default 115200 +config EXAMPLES_NXSCOPE_CDCACM + bool "nxscope CDCACM device support" + depends on CDCACM + default n + endif # LOGGING_NXSCOPE_INTF_SERIAL config EXAMPLES_NXSCOPE_FORCE_ENABLE diff --git a/examples/nxscope/nxscope_main.c b/examples/nxscope/nxscope_main.c index 0d1ff0323..b7eab4a55 100644 --- a/examples/nxscope/nxscope_main.c +++ b/examples/nxscope/nxscope_main.c @@ -24,6 +24,8 @@ #include +#include + #include #include #include @@ -237,6 +239,34 @@ static FAR void *nxscope_crichan_thr(FAR void *arg) } #endif +#ifdef CONFIG_EXAMPLES_NXSCOPE_CDCACM +/**************************************************************************** + * Name: nxscope_cdcacm_init + ****************************************************************************/ + +static int nxscope_cdcacm_init(void) +{ + struct boardioc_usbdev_ctrl_s ctrl; + FAR void *handle; + int ret = OK; + + ctrl.usbdev = BOARDIOC_USBDEV_CDCACM; + ctrl.action = BOARDIOC_USBDEV_CONNECT; + ctrl.instance = 0; + ctrl.handle = &handle; + + ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl); + if (ret < 0) + { + printf("ERROR: BOARDIOC_USBDEV_CONTROL failed %d\n", ret); + goto errout; + } + +errout: + return ret; +} +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -263,6 +293,29 @@ int main(int argc, FAR char *argv[]) struct nxscope_dummy_cfg_s nxs_dummy_cfg; #endif +#ifndef CONFIG_NSH_ARCHINIT + /* Perform architecture-specific initialization (if configured) */ + + boardctl(BOARDIOC_INIT, 0); + +# ifdef CONFIG_BOARDCTL_FINALINIT + /* Perform architecture-specific final-initialization (if configured) */ + + boardctl(BOARDIOC_FINALINIT, 0); +# endif +#endif + +#ifdef CONFIG_EXAMPLES_NXSCOPE_CDCACM + /* Initialize the USB CDCACM device */ + + ret = nxscope_cdcacm_init(); + if (ret < 0) + { + printf("ERROR: nxscope_cdcacm_init failed %d\n", ret); + goto errout_noproto; + } +#endif + /* Default serial protocol */ ret = nxscope_proto_ser_init(&proto, NULL);