Add debug output if trace disabled
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@973 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
8b07c901cd
commit
75c2fb5635
@ -37,8 +37,6 @@ USBDEV_ASRCS =
|
||||
USBDEV_CSRCS =
|
||||
|
||||
ifeq ($(CONFIG_USBDEV),y)
|
||||
ifeq ($(CONFIG_USBDEV_TRACE),y)
|
||||
USBDEV_CSRCS += usbdev_trace.c
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/irq.h>
|
||||
#include <nuttx/usbdev_trace.h>
|
||||
@ -201,4 +202,174 @@ int usbtrace_enumerate(trace_callback_t callback, void *arg)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/*******************************************************************************
|
||||
* Name: usbtrace
|
||||
*
|
||||
* Description:
|
||||
* Map trace to simple debug output
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
void usbtrace(uint16 event, uint16 value)
|
||||
{
|
||||
#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_USB)
|
||||
irqstate_t flags;
|
||||
flags = irqsave();
|
||||
switch (event)
|
||||
{
|
||||
case TRACE_DEVINIT:
|
||||
lldbg("USB controller initialization: %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_DEVUNINIT:
|
||||
lldbg("USB controller un-initialization: %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_DEVREGISTER:
|
||||
lldbg("usbdev_register(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_DEVUNREGISTER:
|
||||
lldbg("usbdev_unregister(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_EPCONFIGURE:
|
||||
lldbg("Endpoint configure(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_EPALLOCREQ:
|
||||
lldbg("Endpoint allocreq(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_EPFREEREQ:
|
||||
lldbg("Endpoint freereq(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_EPALLOCBUFFER:
|
||||
lldbg("Endpoint allocbuffer(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_EPFREEBUFFER:
|
||||
lldbg("Endpoint freebuffer(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_EPSUBMIT:
|
||||
lldbg("Endpoint submit(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_EPCANCEL:
|
||||
lldbg("Endpoint cancel(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_EPSTALL:
|
||||
lldbg("Endpoint stall(TRUE): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_EPRESUME:
|
||||
lldbg("Endpoint stall(FALSE): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_DEVALLOCEP:
|
||||
lldbg("Device allocep(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_DEVFREEEP:
|
||||
lldbg("Device freeep(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_DEVGETFRAME:
|
||||
lldbg("Device getframe(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_DEVWAKEUP:
|
||||
lldbg("Device wakeup(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_DEVSELFPOWERED:
|
||||
lldbg("Device selfpowered(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_DEVPULLUP:
|
||||
lldbg("Device pullup(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_CLASSBIND:
|
||||
lldbg("Class bind(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_CLASSUNBIND:
|
||||
lldbg("Class unbind(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_CLASSDISCONNECT:
|
||||
lldbg("Class disconnect(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_CLASSSETUP:
|
||||
lldbg("Class setup(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_CLASSSUSPEND:
|
||||
lldbg("Class suspend(): %04x\n", value);
|
||||
break;
|
||||
|
||||
case TRACE_CLASSRESUME:
|
||||
lldbg("Class resume(): %04x\n", value);
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (TRACE_ID(event))
|
||||
{
|
||||
case TRACE_INTENTRY_ID: /* Interrupt handler entry */
|
||||
lldbg("Interrrupt %d entry: %04x\n", TRACE_DATA(event), value);
|
||||
break;
|
||||
|
||||
case TRACE_INTDECODE_ID: /* Decoded interrupt event */
|
||||
lldbg("Interrrupt decode %d: %04x\n", TRACE_DATA(event), value);
|
||||
break;
|
||||
|
||||
case TRACE_INTEXIT_ID: /* Interrupt handler exit */
|
||||
lldbg("Interrrupt %d exit: %04x\n", TRACE_DATA(event), value);
|
||||
break;
|
||||
|
||||
case TRACE_OUTREQQUEUED_ID: /* Request queued for OUT endpoint */
|
||||
lldbg("EP%d OUT request queued: %04x\n", TRACE_DATA(event), value);
|
||||
break;
|
||||
|
||||
case TRACE_INREQQUEUED_ID: /* Request queued for IN endpoint */
|
||||
lldbg("EP%d IN request queued: %04x\n", TRACE_DATA(event), value);
|
||||
break;
|
||||
|
||||
case TRACE_READ_ID: /* Read (OUT) action */
|
||||
lldbg("EP%d OUT read: %04x\n", TRACE_DATA(event), value);
|
||||
break;
|
||||
|
||||
case TRACE_WRITE_ID: /* Write (IN) action */
|
||||
lldbg("EP%d IN write: %04x\n", TRACE_DATA(event), value);
|
||||
break;
|
||||
|
||||
case TRACE_COMPLETE_ID: /* Request completed */
|
||||
lldbg("EP%d request complete: %04x\n", TRACE_DATA(event), value);
|
||||
break;
|
||||
|
||||
case TRACE_DEVERROR_ID: /* USB controller driver error event */
|
||||
lldbg("Controller error: %02x:%04x\n", TRACE_DATA(event), value);
|
||||
break;
|
||||
|
||||
case TRACE_CLSERROR_ID: /* USB class driver error event */
|
||||
lldbg("Class error: %02x:%04x\n", TRACE_DATA(event), value);
|
||||
break;
|
||||
|
||||
default:
|
||||
lldbg("Unrecognized event: %02x:%02x:%04x\n",
|
||||
TRACE_ID(event), TRACE_DATA(event), value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
irqrestore(flags);
|
||||
#endif /* CONFIG_DEBUG && CONFIG_DEBUG_USB */
|
||||
}
|
||||
|
||||
#endif /* CONFIG_USBDEV_TRACE */
|
||||
|
@ -49,7 +49,7 @@
|
||||
|
||||
#define TRACE_EVENT(id,data) ((uint16)(id)|(data))
|
||||
#define TRACE_ID(event) ((event)&0xff00)
|
||||
#define TRACE_DATA(event) ((event)0x00ff)
|
||||
#define TRACE_DATA(event) ((event)&0x00ff)
|
||||
|
||||
/* Event class IDs */
|
||||
|
||||
@ -60,12 +60,15 @@
|
||||
#define TRACE_INTENTRY_ID (0x0400) /* Interrupt handler entry */
|
||||
#define TRACE_INTDECODE_ID (0x0500) /* Decoded interrupt event */
|
||||
#define TRACE_INTEXIT_ID (0x0600) /* Interrupt handler exit */
|
||||
#define TRACE_REQQUEUED_ID (0x0700) /* Request queued */
|
||||
#define TRACE_READ_ID (0x0800) /* Read (OUT) action */
|
||||
#define TRACE_WRITE_ID (0x0900) /* Write (IN) action */
|
||||
#define TRACE_COMPLETE_ID (0x0a00) /* Request completed */
|
||||
#define TRACE_DEVERROR_ID (0x0b00) /* USB controller driver error event */
|
||||
#define TRACE_CLSERROR_ID (0x0c00) /* USB class driver error event */
|
||||
#define TRACE_OUTREQQUEUED_ID (0x0700) /* Request queued for OUT endpoint */
|
||||
#define TRACE_INREQQUEUED_ID (0x0800) /* Request queued for IN endpoint */
|
||||
#define TRACE_READ_ID (0x0900) /* Read (OUT) action */
|
||||
#define TRACE_WRITE_ID (0x0a00) /* Write (IN) action */
|
||||
#define TRACE_COMPLETE_ID (0x0b00) /* Request completed */
|
||||
#define TRACE_DEVERROR_ID (0x0c00) /* USB controller driver error event */
|
||||
#define TRACE_CLSERROR_ID (0x0d00) /* USB class driver error event */
|
||||
|
||||
#define TRACE_NIDS 14
|
||||
|
||||
/* Initialization events */
|
||||
|
||||
@ -112,7 +115,8 @@
|
||||
|
||||
/* Data Transfer */
|
||||
|
||||
#define TRACE_REQQUEUED(ep) TRACE_EVENT(TRACE_REQQUEUED_ID, ep)
|
||||
#define TRACE_OUTREQQUEUED(ep) TRACE_EVENT(TRACE_OUTREQQUEUED_ID, ep)
|
||||
#define TRACE_INREQQUEUED(ep) TRACE_EVENT(TRACE_INREQQUEUED_ID, ep)
|
||||
#define TRACE_READ(ep) TRACE_EVENT(TRACE_READ_ID, ep)
|
||||
#define TRACE_WRITE(ep) TRACE_EVENT(TRACE_WRITE_ID, ep)
|
||||
#define TRACE_COMPLETE(ep) TRACE_EVENT(TRACE_COMPLETE_ID, ep)
|
||||
@ -212,7 +216,7 @@ EXTERN void usbtrace_enable(boolean enable);
|
||||
*
|
||||
*******************************************************************************/
|
||||
|
||||
#ifdef CONFIG_USBDEV_TRACE
|
||||
#if defined(CONFIG_USBDEV_TRACE) || (defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_USB))
|
||||
EXTERN void usbtrace(uint16 event, uint16 value);
|
||||
#else
|
||||
# define usbtrace(event, value)
|
||||
@ -231,7 +235,6 @@ EXTERN void usbtrace(uint16 event, uint16 value);
|
||||
|
||||
#ifdef CONFIG_USBDEV_TRACE
|
||||
EXTERN int usbtrace_enumerate(trace_callback_t callback, void *arg);
|
||||
#else
|
||||
# define usbtrace_enumerate(event)
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user