diff options
Diffstat (limited to 'apps/examples/cdcacm')
-rw-r--r-- | apps/examples/cdcacm/cdcacm.h | 42 | ||||
-rw-r--r-- | apps/examples/cdcacm/cdcacm_main.c | 15 |
2 files changed, 54 insertions, 3 deletions
diff --git a/apps/examples/cdcacm/cdcacm.h b/apps/examples/cdcacm/cdcacm.h index 60eada896..ce40e1a93 100644 --- a/apps/examples/cdcacm/cdcacm.h +++ b/apps/examples/cdcacm/cdcacm.h @@ -41,12 +41,14 @@ ****************************************************************************/ #include <nuttx/config.h> + #include <stdlib.h> +#include <nuttx/usb/usbdev_trace.h> + /**************************************************************************** * Pre-Processor Definitions ****************************************************************************/ - /* Configuration ************************************************************/ /* Prerequisites */ @@ -68,6 +70,44 @@ # define CONFIG_EXAMPLES_CDCACM_DEVMINOR 0 #endif +/* Trace Configuration ******************************************************/ + +#ifdef CONFIG_EXAMPLES_CDCACM_TRACEINIT +# define TRACE_INIT_BITS (TRACE_INIT_BIT) +#else +# define TRACE_INIT_BITS (0) +#endif + +#define TRACE_ERROR_BITS (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT) + +#ifdef CONFIG_EXAMPLES_CDCACM_TRACECLASS +# define TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|TRACE_CLASSSTATE_BIT) +#else +# define TRACE_CLASS_BITS (0) +#endif + +#ifdef CONFIG_EXAMPLES_CDCACM_TRACETRANSFERS +# define TRACE_TRANSFER_BITS (TRACE_OUTREQQUEUED_BIT|TRACE_INREQQUEUED_BIT|TRACE_READ_BIT|\ + TRACE_WRITE_BIT|TRACE_COMPLETE_BIT) +#else +# define TRACE_TRANSFER_BITS (0) +#endif + +#ifdef CONFIG_EXAMPLES_CDCACM_TRACECONTROLLER +# define TRACE_CONTROLLER_BITS (TRACE_EP_BIT|TRACE_DEV_BIT) +#else +# define TRACE_CONTROLLER_BITS (0) +#endif + +#ifdef CONFIG_EXAMPLES_CDCACM_TRACEINTERRUPTS +# define TRACE_INTERRUPT_BITS (TRACE_INTENTRY_BIT|TRACE_INTDECODE_BIT|TRACE_INTEXIT_BIT) +#else +# define TRACE_INTERRUPT_BITS (0) +#endif + +#define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|TRACE_CLASS_BITS|\ + TRACE_TRANSFER_BITS|TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS) + /* Debug ********************************************************************/ #ifdef CONFIG_CPP_HAVE_VARARGS diff --git a/apps/examples/cdcacm/cdcacm_main.c b/apps/examples/cdcacm/cdcacm_main.c index 94afe3a58..aeb7a9e74 100644 --- a/apps/examples/cdcacm/cdcacm_main.c +++ b/apps/examples/cdcacm/cdcacm_main.c @@ -81,7 +81,6 @@ struct cdcacm_state_s g_cdcacm; int sercon_main(int argc, char *argv[]) { - FAR void *handle; int ret; /* Check if there is a non-NULL USB mass storage device handle (meaning that the @@ -94,7 +93,13 @@ int sercon_main(int argc, char *argv[]) return EXIT_FAILURE; } - /* Initialize the USB serial driver */ + /* Then, in any event, enable trace data collection as configured BEFORE + * enabling the CDC/ACM device. + */ + + usbtrace_enable(TRACE_BITSET); + + /* Initialize the USB CDC/ACM serial driver */ message("sercon: Registering CDC/ACM serial driver\n"); ret = cdcacm_initialize(CONFIG_EXAMPLES_CDCACM_DEVMINOR, &g_cdcacm.handle); @@ -127,6 +132,12 @@ int serdis_main(int argc, char *argv[]) return EXIT_FAILURE; } + /* Then, in any event, disable trace data collection as configured BEFORE + * enabling the CDC/ACM device. + */ + + usbtrace_enable(0); + /* Then disconnect the device and uninitialize the USB mass storage driver */ cdcacm_uninitialize(g_cdcacm.handle); |