diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-02-15 14:37:37 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-02-15 14:37:37 +0000 |
commit | 327fb90cd335dc8d61d66c81487f73a5fc6f19a5 (patch) | |
tree | 7783ffd51c6a828b6b135733f489a14d45734f68 /nuttx/drivers/usbdev | |
parent | 6132a9da939698fe9d5d3a7310d1287d5cb7a1a7 (diff) | |
download | px4-nuttx-327fb90cd335dc8d61d66c81487f73a5fc6f19a5.tar.gz px4-nuttx-327fb90cd335dc8d61d66c81487f73a5fc6f19a5.tar.bz2 px4-nuttx-327fb90cd335dc8d61d66c81487f73a5fc6f19a5.zip |
STM32 F4 patches from Petteri Aimonen (mostly USB)
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5652 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/usbdev')
-rw-r--r-- | nuttx/drivers/usbdev/Kconfig | 15 | ||||
-rw-r--r-- | nuttx/drivers/usbdev/usbdev_trprintf.c | 40 |
2 files changed, 54 insertions, 1 deletions
diff --git a/nuttx/drivers/usbdev/Kconfig b/nuttx/drivers/usbdev/Kconfig index 0752bb791..f8e21c143 100644 --- a/nuttx/drivers/usbdev/Kconfig +++ b/nuttx/drivers/usbdev/Kconfig @@ -83,6 +83,21 @@ config USBDEV_TRACE_NRECORDS ---help--- Number of trace entries to remember +config USBDEV_TRACE_STRINGS +bool "Decode device controller events" + default n + depends on USBDEV_TRACE + ---help--- + If USBDEV_TRACE_STRINGS is defined, then the USB device controller + driver must provide arrays of strings to support decoding of device- + specific trace events. These arrays of strings (and the type struct + trace_msg_t) are defined in include/nuttx/usb/usbdev_trace.h: + + #ifdef CONFIG_USBDEV_TRACE_STRINGS + extern const struct trace_msg_t g_usb_trace_strings_deverror[]; + extern const struct trace_msg_t g_usb_trace_strings_intdecode[]; + #endif + endmenu menuconfig USBDEV_COMPOSITE diff --git a/nuttx/drivers/usbdev/usbdev_trprintf.c b/nuttx/drivers/usbdev/usbdev_trprintf.c index 2a9921f98..edaa89685 100644 --- a/nuttx/drivers/usbdev/usbdev_trprintf.c +++ b/nuttx/drivers/usbdev/usbdev_trprintf.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/usbdev/usbdev_trprintf.c * - * Copyright (C) 2008-2010, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -65,6 +65,32 @@ * Private Functions ****************************************************************************/ +/******************************************************************************* + * Name: get_string + * + * Description: + * Search the driver string data to find the string matching the provided ID. + * + *******************************************************************************/ + +#ifdef CONFIG_USBDEV_TRACE_STRINGS +static FAR const char *get_string(FAR const struct trace_msg_t *array, int id) +{ + FAR const struct trace_msg_t *p = array; + while (p->str != NULL) + { + if (p->id == id) + { + return p->str; + } + p++; + } + + return "???"; +} + +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -209,7 +235,13 @@ void usbtrace_trprintf(trprintf_t trprintf, uint16_t event, uint16_t value) break; case TRACE_INTDECODE_ID: /* Decoded interrupt event */ +#ifdef CONFIG_USBDEV_TRACE_STRINGS + trprintf("Interrupt decode %3d: %-40s %04x\n", TRACE_DATA(event), + get_string(g_usb_trace_strings_intdecode, TRACE_DATA(event)), + value); +#else trprintf("Interrupt decode %d: %04x\n", TRACE_DATA(event), value); +#endif break; case TRACE_INTEXIT_ID: /* Interrupt handler exit */ @@ -237,7 +269,13 @@ void usbtrace_trprintf(trprintf_t trprintf, uint16_t event, uint16_t value) break; case TRACE_DEVERROR_ID: /* USB controller driver error event */ +#ifdef CONFIG_USBDEV_TRACE_STRINGS + trprintf("Controller error: %02x: %-40s %04x\n", TRACE_DATA(event), + get_string(g_usb_trace_strings_deverror, TRACE_DATA(event)), + value); +#else trprintf("Controller error: %02x:%04x\n", TRACE_DATA(event), value); +#endif break; case TRACE_CLSERROR_ID: /* USB class driver error event */ |