summaryrefslogtreecommitdiff
path: root/apps/nshlib/nsh_usbdev.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-26 18:05:26 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-26 18:05:26 +0000
commit1caf0a84f85f55d2d34066797cd46ecea8c7627e (patch)
tree79d45d0fafaa9a0386e6c52ebcef2fc2d09233d4 /apps/nshlib/nsh_usbdev.c
parent43a2d9869b3d779403c65fa99a8ba820af57ffa9 (diff)
downloadpx4-nuttx-1caf0a84f85f55d2d34066797cd46ecea8c7627e.tar.gz
px4-nuttx-1caf0a84f85f55d2d34066797cd46ecea8c7627e.tar.bz2
px4-nuttx-1caf0a84f85f55d2d34066797cd46ecea8c7627e.zip
Add support for the USB trace cability in NSH when a USB console is used
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4774 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/nshlib/nsh_usbdev.c')
-rw-r--r--apps/nshlib/nsh_usbdev.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/apps/nshlib/nsh_usbdev.c b/apps/nshlib/nsh_usbdev.c
index 40e35d5f4..3d123532a 100644
--- a/apps/nshlib/nsh_usbdev.c
+++ b/apps/nshlib/nsh_usbdev.c
@@ -44,6 +44,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
+#include <debug.h>
#ifdef CONFIG_CDCACM
# include <nuttx/usb/cdcacm.h>
@@ -61,6 +62,12 @@
* Definitions
****************************************************************************/
+#if defined(CONFIG_DEBUG) || defined(CONFIG_NSH_USBCONSOLE)
+# define trmessage lib_lowprintf
+#else
+# define trmessage printf
+#endif
+
/****************************************************************************
* Private Types
****************************************************************************/
@@ -82,6 +89,18 @@
****************************************************************************/
/****************************************************************************
+ * Name: nsh_tracecallback
+ ****************************************************************************/
+
+#ifdef CONFIG_USBDEV_TRACE
+static int nsh_tracecallback(struct usbtrace_s *trace, void *arg)
+{
+ usbtrace_trprintf((trprintf_t)trmessage, trace->event, trace->value);
+ return 0;
+}
+#endif
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -100,7 +119,9 @@ int nsh_usbconsole(void)
/* Initialize any USB tracing options that were requested */
- usbtrace_enable(CONFIG_NSH_UBSDEV_TRACEINIT);
+#ifdef CONFIG_USBDEV_TRACE
+ usbtrace_enable(TRACE_BITSET);
+#endif
/* Don't start the NSH console until the console device is ready. Chances
* are, we get here with no functional console. The USB console will not
@@ -207,4 +228,16 @@ int nsh_usbconsole(void)
}
#endif /* HAVE_USB_CONSOLE */
+
+/****************************************************************************
+ * Name: nsh_usbtrace
+ ****************************************************************************/
+
+#if defined(CONFIG_USBDEV_TRACE) && defined(HAVE_USB_CONSOLE)
+void nsh_usbtrace(void)
+{
+ (void)usbtrace_enumerate(nsh_tracecallback, NULL);
+}
+#endif
+
#endif /* CONFIG_USBDEV */