diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-04-12 08:44:22 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-04-12 08:44:22 -0600 |
commit | 891b20aff2fb5e52ff357e6208bb859a99cd7127 (patch) | |
tree | af802148a4a28c55558d1720559702be01f93e28 | |
parent | b315074b5c8fe058fdab4e163939b6402b58deff (diff) | |
download | nuttx-891b20aff2fb5e52ff357e6208bb859a99cd7127.tar.gz nuttx-891b20aff2fb5e52ff357e6208bb859a99cd7127.tar.bz2 nuttx-891b20aff2fb5e52ff357e6208bb859a99cd7127.zip |
STM32 OTGFS: Host USB tracing instrumentation added by Leo
-rw-r--r-- | nuttx/ChangeLog | 3 | ||||
-rw-r--r-- | nuttx/arch/arm/src/sama5/sam_usbhost.c | 2 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/Make.defs | 12 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_otgfshost.c | 117 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/stm32/stm32_usbhost.c | 190 | ||||
-rw-r--r-- | nuttx/arch/arm/src/stm32/stm32_usbhost.h | 78 |
6 files changed, 375 insertions, 27 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 6258c1f86..b82a9fec8 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -7169,4 +7169,5 @@ also the camera/ISI interface reset line. So if the a camera is installed, then we must avoid controlling the red LED or we inadvertently also reset the camera module. Noted by David Sidrane (2014-4-11). - + * arch/arm/src/stm32/stm32_usbhost.c/.h and stm32_otgfshost.c: USB host + tracing added by Leo (2014-4-12). diff --git a/nuttx/arch/arm/src/sama5/sam_usbhost.c b/nuttx/arch/arm/src/sama5/sam_usbhost.c index 86bbbc1b2..89a63bea6 100644 --- a/nuttx/arch/arm/src/sama5/sam_usbhost.c +++ b/nuttx/arch/arm/src/sama5/sam_usbhost.c @@ -1,5 +1,5 @@ /******************************************************************************************** - * arch/arm/src/sama5/sam_host.c + * arch/arm/src/sama5/sam_usbhost.c * * Copyright (C) 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> diff --git a/nuttx/arch/arm/src/stm32/Make.defs b/nuttx/arch/arm/src/stm32/Make.defs index c65a227b5..41a22a607 100644 --- a/nuttx/arch/arm/src/stm32/Make.defs +++ b/nuttx/arch/arm/src/stm32/Make.defs @@ -1,7 +1,7 @@ ############################################################################ # arch/arm/src/stm32/Make.defs # -# Copyright (C) 2009, 2011-2013 Gregory Nutt. All rights reserved. +# Copyright (C) 2009, 2011-2014 Gregory Nutt. All rights reserved. # Author: Gregory Nutt <gnutt@nuttx.org> # # Redistribution and use in source and binary forms, with or without @@ -132,6 +132,16 @@ CHIP_CSRCS += stm32_otgfshost.c endif endif +ifeq ($(CONFIG_USBHOST),y) +ifeq ($(CONFIG_USBHOST_TRACE),y) +CHIP_CSRCS += stm32_usbhost.c +else +ifeq ($(CONFIG_DEBUG_USB),y) +CHIP_CSRCS += stm32_usbhost.c +endif +endif +endif + ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y) CHIP_CSRCS += stm32_idle.c endif diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfshost.c b/nuttx/arch/arm/src/stm32/stm32_otgfshost.c index 7392db2c7..0f70a521e 100644 --- a/nuttx/arch/arm/src/stm32/stm32_otgfshost.c +++ b/nuttx/arch/arm/src/stm32/stm32_otgfshost.c @@ -1,7 +1,7 @@ /******************************************************************************* * arch/arm/src/stm32/stm32_otgfshost.c * - * Copyright (C) 2012-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2014 Gregory Nutt. All rights reserved. * Authors: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -54,6 +54,7 @@ #include <nuttx/clock.h> #include <nuttx/usb/usb.h> #include <nuttx/usb/usbhost.h> +#include <nuttx/usb/usbhost_trace.h> #include <arch/irq.h> @@ -718,6 +719,20 @@ static void stm32_chan_configure(FAR struct stm32_usbhost_s *priv, int chidx) switch (priv->chan[chidx].eptype) { case OTGFS_EPTYPE_CTRL: + { + if (priv->chan[chidx].in) + { + usbhost_vtrace2(OTGFS_VTRACE2_CHANCONF_CTRL_IN, chidx, + priv->chan[chidx].epno); + } + else + { + usbhost_vtrace2(OTGFS_VTRACE2_CHANCONF_CTRL_OUT, chidx, + priv->chan[chidx].epno); + } + } + break; + case OTGFS_EPTYPE_BULK: { /* Interrupts required for CTRL and BULK endpoints */ @@ -729,10 +744,14 @@ static void stm32_chan_configure(FAR struct stm32_usbhost_s *priv, int chidx) if (priv->chan[chidx].in) { + usbhost_vtrace2(OTGFS_VTRACE2_CHANCONF_BULK_IN, chidx, + priv->chan[chidx].epno); regval |= OTGFS_HCINT_BBERR; } else { + usbhost_vtrace2(OTGFS_VTRACE2_CHANCONF_BULK_OUT, chidx, + priv->chan[chidx].epno); regval |= OTGFS_HCINT_NYET; } } @@ -749,8 +768,15 @@ static void stm32_chan_configure(FAR struct stm32_usbhost_s *priv, int chidx) if (priv->chan[chidx].in) { + usbhost_vtrace2(OTGFS_VTRACE2_CHANCONF_INTR_IN, chidx, + priv->chan[chidx].epno); regval |= OTGFS_HCINT_BBERR; } + else + { + usbhost_vtrace2(OTGFS_VTRACE2_CHANCONF_INTR_OUT, chidx, + priv->chan[chidx].epno); + } } break; @@ -764,8 +790,15 @@ static void stm32_chan_configure(FAR struct stm32_usbhost_s *priv, int chidx) if (priv->chan[chidx].in) { + usbhost_vtrace2(OTGFS_VTRACE2_CHANCONF_ISOC_IN, chidx, + priv->chan[chidx].epno); regval |= (OTGFS_HCINT_TXERR | OTGFS_HCINT_BBERR); } + else + { + usbhost_vtrace2(OTGFS_VTRACE2_CHANCONF_ISOC_OUT, chidx, + priv->chan[chidx].epno); + } } break; } @@ -834,6 +867,8 @@ static void stm32_chan_halt(FAR struct stm32_usbhost_s *priv, int chidx, * handling logic to know what to do next. */ + usbhost_trace2(OTGFS_VTRACE2_CHANHALT, chidx, chreason); + priv->chan[chidx].chreason = (uint8_t)chreason; /* "The application can disable any channel by programming the OTG_FS_HCCHARx @@ -1009,7 +1044,17 @@ static void stm32_chan_wakeup(FAR struct stm32_usbhost_s *priv, if (chan->result != EBUSY && chan->waiter) { - ullvdbg("Wakeup with result: %d\n", chan->result); + if (chan->in) + { + usbhost_vtrace2(OTGFS_VTRACE2_CHANWAKEUP_IN, chan->epno, + chan->result); + } + else + { + usbhost_vtrace2(OTGFS_VTRACE2_CHANWAKEUP_OUT, chan->epno, + chan->result); + } + stm32_givesem(&chan->waitsem); chan->waiter = false; } @@ -1036,7 +1081,8 @@ static void stm32_transfer_start(FAR struct stm32_usbhost_s *priv, int chidx) /* Set up the initial state of the transfer */ chan = &priv->chan[chidx]; - uvdbg("chidx: %d buflen: %d\n", chidx, chan->buflen); + + usbhost_vtrace2(OTGFS_VTRACE2_STARTTRANSFER, chidx, chan->buflen); chan->result = EBUSY; chan->inflight = 0; @@ -1066,7 +1112,8 @@ static void stm32_transfer_start(FAR struct stm32_usbhost_s *priv, int chidx) { npackets = STM32_MAX_PKTCOUNT; chan->buflen = STM32_MAX_PKTCOUNT * maxpacket; - ulldbg("CLIP: chidx: %d buflen: %d\n", chidx, chan->buflen); + + usbhost_trace2(OTGFS_TRACE2_CLIP, chidx, chan->buflen); } } else @@ -1250,7 +1297,7 @@ static int stm32_ctrl_sendsetup(FAR struct stm32_usbhost_s *priv, ret = stm32_chan_waitsetup(priv, chan); if (ret != OK) { - udbg("ERROR: Device disconnected\n"); + usbhost_trace1(OTGFS_TRACE1_DEVDISCONN, 0); return ret; } @@ -1273,7 +1320,7 @@ static int stm32_ctrl_sendsetup(FAR struct stm32_usbhost_s *priv, if (ret < 0) { - udbg("Transfer failed: %d\n", ret); + usbhost_trace1(OTGFS_TRACE1_TRNSFRFAILED, ret); } /* Return the result in any event */ @@ -1328,7 +1375,7 @@ static int stm32_ctrl_senddata(FAR struct stm32_usbhost_s *priv, ret = stm32_chan_waitsetup(priv, chan); if (ret != OK) { - udbg("ERROR: Device disconnected\n"); + usbhost_trace1(OTGFS_TRACE1_DEVDISCONN, 0); return ret; } @@ -1367,7 +1414,7 @@ static int stm32_ctrl_recvdata(FAR struct stm32_usbhost_s *priv, ret = stm32_chan_waitsetup(priv, chan); if (ret != OK) { - udbg("ERROR: Device disconnected\n"); + usbhost_trace1(OTGFS_TRACE1_DEVDISCONN, 0); return ret; } @@ -1412,7 +1459,7 @@ static int stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx, ret = stm32_chan_waitsetup(priv, chan); if (ret != OK) { - udbg("ERROR: Device disconnected\n"); + usbhost_trace1(OTGFS_TRACE1_DEVDISCONN, 0); return ret; } @@ -1434,15 +1481,25 @@ static int stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx, { /* Set up the IN data PID */ + usbhost_trace2(OTGFS_VTRACE2_ISOCIN, chidx, buflen); chan->pid = OTGFS_PID_DATA0; } break; case OTGFS_EPTYPE_BULK: /* Bulk */ + { + /* Setup the IN data PID */ + + usbhost_trace2(OTGFS_VTRACE2_BULKIN, chidx, buflen); + chan->pid = chan->indata1 ? OTGFS_PID_DATA1 : OTGFS_PID_DATA0; + } + break; + case OTGFS_EPTYPE_INTR: /* Interrupt */ { /* Setup the IN data PID */ + usbhost_trace2(OTGFS_VTRACE2_INTRIN, chidx, buflen); chan->pid = chan->indata1 ? OTGFS_PID_DATA1 : OTGFS_PID_DATA0; } break; @@ -1463,7 +1520,7 @@ static int stm32_in_transfer(FAR struct stm32_usbhost_s *priv, int chidx, if (ret != OK) { - udbg("Transfer failed: %d\n", ret); + usbhost_trace1(OTGFS_TRACE1_TRNSFRFAILED,ret); /* Check for a special case: If (1) the transfer was NAKed and (2) * no Tx FIFO empty or Rx FIFO not-empty event occurred, then we @@ -1527,7 +1584,7 @@ static int stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, ret = stm32_chan_waitsetup(priv, chan); if (ret != OK) { - udbg("ERROR: Device disconnected\n"); + usbhost_trace1(OTGFS_TRACE1_DEVDISCONN,0); return ret; } @@ -1549,6 +1606,7 @@ static int stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, { /* Set up the OUT data PID */ + usbhost_trace2(OTGFS_VTRACE2_ISOCOUT, chidx, buflen); chan->pid = OTGFS_PID_DATA0; } break; @@ -1557,6 +1615,7 @@ static int stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, { /* Setup the OUT data PID */ + usbhost_trace2(OTGFS_VTRACE2_BULKOUT, chidx, buflen); chan->pid = chan->outdata1 ? OTGFS_PID_DATA1 : OTGFS_PID_DATA0; } break; @@ -1565,12 +1624,14 @@ static int stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, { /* Setup the OUT data PID */ + usbhost_trace2(OTGFS_VTRACE2_INTROUT, chidx, buflen); chan->pid = chan->outdata1 ? OTGFS_PID_DATA1 : OTGFS_PID_DATA0; /* Toggle the OUT data PID for the next transfer */ chan->outdata1 ^= true; } + break; } /* Start the transfer */ @@ -1585,7 +1646,7 @@ static int stm32_out_transfer(FAR struct stm32_usbhost_s *priv, int chidx, if (ret != OK) { - udbg("Transfer failed: %d\n", ret); + usbhost_trace1(OTGFS_TRACE1_TRNSFRFAILED,ret); /* Check for a special case: If (1) the transfer was NAKed and (2) * no Tx FIFO empty or Rx FIFO not-empty event occurred, then we @@ -2167,7 +2228,7 @@ static void stm32_gint_connected(FAR struct stm32_usbhost_s *priv) { /* Yes.. then now we are connected */ - ullvdbg("Connected\n"); + usbhost_vtrace1(OTGFS_VTRACE1_CONNECTED,0); priv->connected = true; DEBUGASSERT(priv->smstate == SMSTATE_DETACHED); @@ -2198,7 +2259,7 @@ static void stm32_gint_disconnected(FAR struct stm32_usbhost_s *priv) { /* Yes.. then we no longer connected */ - ullvdbg("Disconnected\n"); + usbhost_vtrace1(OTGFS_VTRACE1_DISCONNECTED,0); /* Are we bound to a class driver? */ @@ -2789,13 +2850,14 @@ static int stm32_gint_isr(int irq, FAR void *context) /* Otherwise, process each pending, unmasked GINT interrupts */ - ullvdbg("GINTSTS: %08x\n", pending); + usbhost_vtrace1(OTGFS_VTRACE1_GINT, 0); /* Handle the start of frame interrupt */ #ifdef CONFIG_STM32_OTGFS_SOFINTR if ((pending & OTGFS_GINT_SOF) != 0) { + usbhost_vtrace1(OTGFS_VTRACE1_GINT_SOF, 0); stm32_gint_sofisr(priv); } #endif @@ -2804,6 +2866,7 @@ static int stm32_gint_isr(int irq, FAR void *context) if ((pending & OTGFS_GINT_RXFLVL) != 0) { + usbhost_vtrace1(OTGFS_VTRACE1_GINT_RXFLVL, 0); stm32_gint_rxflvlisr(priv); } @@ -2811,6 +2874,7 @@ static int stm32_gint_isr(int irq, FAR void *context) if ((pending & OTGFS_GINT_NPTXFE) != 0) { + usbhost_vtrace1(OTGFS_VTRACE1_GINT_NPTXFE, 0); stm32_gint_nptxfeisr(priv); } @@ -2818,6 +2882,7 @@ static int stm32_gint_isr(int irq, FAR void *context) if ((pending & OTGFS_GINT_PTXFE) != 0) { + usbhost_vtrace1(OTGFS_VTRACE1_GINT_PTXFE, 0); stm32_gint_ptxfeisr(priv); } @@ -2825,6 +2890,7 @@ static int stm32_gint_isr(int irq, FAR void *context) if ((pending & OTGFS_GINT_HC) != 0) { + usbhost_vtrace1(OTGFS_VTRACE1_GINT_HC, 0); stm32_gint_hcisr(priv); } @@ -2832,6 +2898,7 @@ static int stm32_gint_isr(int irq, FAR void *context) if ((pending & OTGFS_GINT_HPRT) != 0) { + usbhost_vtrace1(OTGFS_VTRACE1_GINT_HPRT, 0); stm32_gint_hprtisr(priv); } @@ -2839,6 +2906,7 @@ static int stm32_gint_isr(int irq, FAR void *context) if ((pending & OTGFS_GINT_DISC) != 0) { + usbhost_vtrace1(OTGFS_VTRACE1_GINT_DISC, 0); stm32_gint_discisr(priv); } @@ -2846,6 +2914,7 @@ static int stm32_gint_isr(int irq, FAR void *context) if ((pending & OTGFS_GINT_IISOOXFR) != 0) { + usbhost_vtrace1(OTGFS_VTRACE1_GINT_IISOOXFR, 0); stm32_gint_iisooxfrisr(priv); } } @@ -3115,7 +3184,7 @@ static int stm32_enumerate(FAR struct usbhost_connection_s *conn, int rhpndx) { /* No, return an error */ - udbg("Not connected\n"); + usbhost_trace1(OTGFS_TRACE1_DEVDISCONN,0); return -ENODEV; } @@ -3606,6 +3675,7 @@ static int stm32_ctrlin(FAR struct usbhost_driver_s *drvr, int ret; DEBUGASSERT(drvr && req); + usbhost_vtrace2(OTGFS_VTRACE2_CTRLIN, req->type, req->req); uvdbg("type:%02x req:%02x value:%02x%02x index:%02x%02x len:%02x%02x\n", req->type, req->req, req->value[1], req->value[0], req->index[1], req->index[0], req->len[1], req->len[0]); @@ -3627,7 +3697,7 @@ static int stm32_ctrlin(FAR struct usbhost_driver_s *drvr, ret = stm32_ctrl_sendsetup(priv, req); if (ret < 0) { - udbg("stm32_ctrl_sendsetup failed: %d\n", ret); + usbhost_trace1(OTGFS_TRACE1_SENDSETUP, -ret); continue; } @@ -3643,7 +3713,7 @@ static int stm32_ctrlin(FAR struct usbhost_driver_s *drvr, ret = stm32_ctrl_recvdata(priv, buffer, buflen); if (ret < 0) { - udbg("stm32_ctrl_recvdata failed: %d\n", ret); + usbhost_trace1(OTGFS_TRACE1_RECVDATA, -ret); } } @@ -3661,7 +3731,7 @@ static int stm32_ctrlin(FAR struct usbhost_driver_s *drvr, return OK; } - udbg("stm32_ctrl_senddata failed: %d\n", ret); + usbhost_trace1(OTGFS_TRACE1_SENDDATA, ret < 0 ? -ret : ret); } /* Get the elapsed time (in frames) */ @@ -3689,6 +3759,7 @@ static int stm32_ctrlout(FAR struct usbhost_driver_s *drvr, int ret; DEBUGASSERT(drvr && req); + usbhost_vtrace2(OTGFS_VTRACE2_CTRLOUT, req->type, req->req); uvdbg("type:%02x req:%02x value:%02x%02x index:%02x%02x len:%02x%02x\n", req->type, req->req, req->value[1], req->value[0], req->index[1], req->index[0], req->len[1], req->len[0]); @@ -3712,7 +3783,7 @@ static int stm32_ctrlout(FAR struct usbhost_driver_s *drvr, ret = stm32_ctrl_sendsetup(priv, req); if (ret < 0) { - udbg("stm32_ctrl_sendsetup failed: %d\n", ret); + usbhost_trace1(OTGFS_TRACE1_SENDSETUP, -ret); continue; } @@ -3731,7 +3802,7 @@ static int stm32_ctrlout(FAR struct usbhost_driver_s *drvr, ret = stm32_ctrl_senddata(priv, NULL, 0); if (ret < 0) { - udbg("stm32_ctrl_senddata failed: %d\n", ret); + usbhost_trace1(OTGFS_TRACE1_SENDDATA, -ret); } } @@ -3748,7 +3819,7 @@ static int stm32_ctrlout(FAR struct usbhost_driver_s *drvr, return OK; } - udbg("stm32_ctrl_recvdata failed: %d\n", ret); + usbhost_trace1(OTGFS_TRACE1_RECVDATA, ret < 0 ? -ret : ret); } /* Get the elapsed time (in frames) */ @@ -4341,7 +4412,7 @@ FAR struct usbhost_connection_s *stm32_otgfshost_initialize(int controller) if (irq_attach(STM32_IRQ_OTGFS, stm32_gint_isr) != 0) { - udbg("Failed to attach IRQ\n"); + usbhost_trace1(OTGFS_TRACE1_IRQATTACH, 0); return NULL; } diff --git a/nuttx/arch/arm/src/stm32/stm32_usbhost.c b/nuttx/arch/arm/src/stm32/stm32_usbhost.c new file mode 100755 index 000000000..9f1f0f7ec --- /dev/null +++ b/nuttx/arch/arm/src/stm32/stm32_usbhost.c @@ -0,0 +1,190 @@ +/******************************************************************************************** + * arch/arm/src/stm32/stm32_usbhost.c + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ********************************************************************************************/ + +/******************************************************************************************** + * Included Files + ********************************************************************************************/ + +#include <nuttx/config.h> + +#include <stdint.h> +#include <stdbool.h> +#include <assert.h> + +#include <nuttx/usb/usbhost_trace.h> + +#include "stm32_usbhost.h" + +#ifdef HAVE_USBHOST_TRACE + +/******************************************************************************************** + * Pre-processor Definitions + ********************************************************************************************/ + +#define TR_FMT1 false +#define TR_FMT2 true + +#define TRENTRY(id,fmt1,string) {string} + +#ifndef NULL +# define NULL ((FAR void *)0) +#endif + +/******************************************************************************************** + * Private Types + ********************************************************************************************/ + +struct stm32_usbhost_trace_s +{ +#if 0 + uint16_t id; + bool fmt2; +#endif + FAR const char *string; +}; + +/******************************************************************************************** + * Private Data + ********************************************************************************************/ + +static const struct stm32_usbhost_trace_s g_trace1[TRACE1_NSTRINGS] = +{ +#ifdef CONFIG_STM32_OTGFS + + TRENTRY(OTGFS_TRACE1_DEVDISCONN, TR_FMT1, "OTGFS ERROR: Host Port %d. Device disconnected\n"), + TRENTRY(OTGFS_TRACE1_IRQATTACH, TR_FMT1, "OTGFS ERROR: Failed to attach IRQ\n"), + TRENTRY(OTGFS_TRACE1_TRNSFRFAILED, TR_FMT1, "OTGFS ERROR: Transfer Failed. ret=%d\n"), + TRENTRY(OTGFS_TRACE1_SENDSETUP, TR_FMT1, "OTGFS ERROR: ctrl_sendsetup() failed with: %d\n"), + TRENTRY(OTGFS_TRACE1_SENDDATA, TR_FMT1, "OTGFS ERROR: ctrl_senddata() failed with: %d\n"), + TRENTRY(OTGFS_TRACE1_RECVDATA, TR_FMT1, "OTGFS ERROR: ctrl_recvdata() failed with: %d\n"), + +# ifdef HAVE_USBHOST_TRACE_VERBOSE + + TRENTRY(OTGFS_VTRACE1_CONNECTED, TR_FMT1, "OTGFS Host Port %d connected.\n"), + TRENTRY(OTGFS_VTRACE1_DISCONNECTED, TR_FMT1, "OTGFS Host Port %d disconnected.\n"), + TRENTRY(OTGFS_VTRACE1_GINT, TR_FMT1, "OTGFS Handling Interrupt. Entry Point.\n"), + TRENTRY(OTGFS_VTRACE1_GINT_SOF, TR_FMT1, "OTGFS Handle the start of frame interrupt.\n"), + TRENTRY(OTGFS_VTRACE1_GINT_RXFLVL, TR_FMT1, "OTGFS Handle the RxFIFO non-empty interrupt.\n"), + TRENTRY(OTGFS_VTRACE1_GINT_NPTXFE, TR_FMT1, "OTGFS Handle the non-periodic TxFIFO empty interrupt.\n"), + TRENTRY(OTGFS_VTRACE1_GINT_PTXFE, TR_FMT1, "OTGFS Handle the periodic TxFIFO empty interrupt.\n"), + TRENTRY(OTGFS_VTRACE1_GINT_HC, TR_FMT1, "OTGFS Handle the host channels interrupt.\n"), + TRENTRY(OTGFS_VTRACE1_GINT_HPRT, TR_FMT1, "OTGFS Handle the host port interrupt.\n"), + TRENTRY(OTGFS_VTRACE1_GINT_DISC, TR_FMT1, "OTGFS Handle the disconnect detected interrupt.\n"), + TRENTRY(OTGFS_VTRACE1_GINT_IISOOXFR, TR_FMT1, "OTGFS Handle the incomplete isochronous OUT transfer.\n"), + +# endif +#endif + +}; + +static const struct stm32_usbhost_trace_s g_trace2[TRACE2_NSTRINGS] = +{ +#ifdef CONFIG_STM32_OTGFS + + TRENTRY(OTGFS_TRACE2_CLIP, TR_FMT2, "OTGFS CLIP: chidx: %d buflen: %d\n"), + +# ifdef HAVE_USBHOST_TRACE_VERBOSE + + TRENTRY(OTGFS_VTRACE2_CHANWAKEUP_IN, TR_FMT2, "OTGFS EP%d(IN) wake up with result: %d\n"), + TRENTRY(OTGFS_VTRACE2_CHANWAKEUP_OUT, TR_FMT2, "OTGFS EP%d(OUT) wake up with result: %d\n"), + TRENTRY(OTGFS_VTRACE2_CTRLIN, TR_FMT2, "OTGFS CTRL_IN type: %02x req: %02x\n"), + TRENTRY(OTGFS_VTRACE2_CTRLOUT, TR_FMT2, "OTGFS CTRL_OUT type: %02x req: %02x\n"), + TRENTRY(OTGFS_VTRACE2_INTRIN, TR_FMT2, "OTGFS INTR_IN chidx: %02x len: %02x\n"), + TRENTRY(OTGFS_VTRACE2_INTROUT, TR_FMT2, "OTGFS INTR_OUT chidx: %02x len: %02x\n"), + TRENTRY(OTGFS_VTRACE2_BULKIN, TR_FMT2, "OTGFS BULK_IN chidx: %02x len: %02x\n"), + TRENTRY(OTGFS_VTRACE2_BULKOUT, TR_FMT2, "OTGFS BULK_OUT chidx: %02x len: %02x\n"), + TRENTRY(OTGFS_VTRACE2_ISOCIN, TR_FMT2, "OTGFS ISOC_IN chidx: %02x len: %04d\n"), + TRENTRY(OTGFS_VTRACE2_ISOCOUT, TR_FMT2, "OTGFS ISOC_OUT chidx: %02x req: %02x\n"), + TRENTRY(OTGFS_VTRACE2_STARTTRANSFER, TR_FMT2, "OTGFS Transfer chidx: %d buflen: %d\n"), + TRENTRY(OTGFS_VTRACE2_CHANCONF_CTRL_IN, TR_FMT2, "OTGFS Channel configured. chidx: %d: (EP%d,IN ,CTRL)\n"), + TRENTRY(OTGFS_VTRACE2_CHANCONF_CTRL_OUT, TR_FMT2, "OTGFS Channel configured. chidx: %d: (EP%d,OUT,CTRL)\n"), + TRENTRY(OTGFS_VTRACE2_CHANCONF_INTR_IN, TR_FMT2, "OTGFS Channel configured. chidx: %d: (EP%d,IN ,INTR)\n"), + TRENTRY(OTGFS_VTRACE2_CHANCONF_INTR_OUT, TR_FMT2, "OTGFS Channel configured. chidx: %d: (EP%d,OUT,INTR)\n"), + TRENTRY(OTGFS_VTRACE2_CHANCONF_BULK_IN, TR_FMT2, "OTGFS Channel configured. chidx: %d: (EP%d,IN ,BULK)\n"), + TRENTRY(OTGFS_VTRACE2_CHANCONF_BULK_OUT, TR_FMT2, "OTGFS Channel configured. chidx: %d: (EP%d,OUT,BULK)\n"), + TRENTRY(OTGFS_VTRACE2_CHANCONF_ISOC_IN, TR_FMT2, "OTGFS Channel configured. chidx: %d: (EP%d,IN ,ISOC)\n"), + TRENTRY(OTGFS_VTRACE2_CHANCONF_ISOC_OUT, TR_FMT2, "OTGFS Channel configured. chidx: %d: (EP%d,OUT,ISOC)\n"), + TRENTRY(OTGFS_VTRACE2_CHANHALT, TR_FMT2, "OTGFS Channel halted. chidx: %d, reason: %d\n"), + +# endif +#endif +}; + +/******************************************************************************************** + * Private Function Prototypes + ********************************************************************************************/ + +/******************************************************************************************** + * Global Functions + ********************************************************************************************/ + +/******************************************************************************************** + * Name: usbhost_trformat1 and usbhost_trformat2 + * + * Description: + * This interface must be provided by platform specific logic that knows + * the HCDs encoding of USB trace data. + * + * Given an 9-bit index, return a format string suitable for use with, say, + * printf. The returned format is expected to handle two unsigned integer + * values. + * + ********************************************************************************************/ + +FAR const char *usbhost_trformat1(uint16_t id) +{ + int ndx = TRACE1_INDEX(id); + + if (ndx < TRACE1_NSTRINGS) + { + return g_trace1[ndx].string; + } + + return NULL; +} + +FAR const char *usbhost_trformat2(uint16_t id) +{ + int ndx = TRACE2_INDEX(id); + + if (ndx < TRACE2_NSTRINGS) + { + return g_trace2[ndx].string; + } + + return NULL; +} + +#endif /* HAVE_USBHOST_TRACE */ diff --git a/nuttx/arch/arm/src/stm32/stm32_usbhost.h b/nuttx/arch/arm/src/stm32/stm32_usbhost.h index a0e3b59e2..b3a68cbef 100644 --- a/nuttx/arch/arm/src/stm32/stm32_usbhost.h +++ b/nuttx/arch/arm/src/stm32/stm32_usbhost.h @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/stm32/stm32_usbhost.h * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -49,6 +49,82 @@ #if defined(CONFIG_STM32_OTGFS) && defined(CONFIG_USBHOST) +#ifdef HAVE_USBHOST_TRACE +enum usbhost_trace1codes_e +{ + __TRACE1_BASEVALUE = 0, /* This will force the first value to be 1 */ + +#ifdef CONFIG_STM32_OTGFS + + OTGFS_TRACE1_DEVDISCONN, /* OTGFS ERROR: Host Port Device disconnected */ + OTGFS_TRACE1_IRQATTACH, /* OTGFS ERROR: Failed to attach IRQ */ + OTGFS_TRACE1_TRNSFRFAILED, /* OTGFS ERROR: Host Port Transfer Failed */ + OTGFS_TRACE1_SENDSETUP, /* OTGFS ERROR: sendsetup() failed with: */ + OTGFS_TRACE1_SENDDATA, /* OTGFS ERROR: senddata() failed with: */ + OTGFS_TRACE1_RECVDATA, /* OTGFS ERROR: recvdata() failed with: */ + +# ifdef HAVE_USBHOST_TRACE_VERBOSE + + OTGFS_VTRACE1_CONNECTED, /* OTGFS Host Port connected */ + OTGFS_VTRACE1_DISCONNECTED, /* OTGFS Host Port disconnected */ + OTGFS_VTRACE1_GINT, /* OTGFS Handling Interrupt. Entry Point */ + OTGFS_VTRACE1_GINT_SOF, /* OTGFS Handle the start of frame interrupt */ + OTGFS_VTRACE1_GINT_RXFLVL, /* OTGFS Handle the RxFIFO non-empty interrupt */ + OTGFS_VTRACE1_GINT_NPTXFE, /* OTGFS Handle the non-periodic TxFIFO empty interrupt */ + OTGFS_VTRACE1_GINT_PTXFE, /* OTGFS Handle the periodic TxFIFO empty interrupt */ + OTGFS_VTRACE1_GINT_HC, /* OTGFS Handle the host channels interrupt */ + OTGFS_VTRACE1_GINT_HPRT, /* OTGFS Handle the host port interrupt */ + OTGFS_VTRACE1_GINT_DISC, /* OTGFS Handle the disconnect detected interrupt */ + OTGFS_VTRACE1_GINT_IISOOXFR, /* OTGFS Handle the incomplete isochronous OUT transfer */ + +# endif +#endif + + __TRACE1_NSTRINGS, /* Separates the format 1 from the format 2 strings */ + +#ifdef CONFIG_STM32_OTGFS + + OTGFS_TRACE2_CLIP, /* OTGFS CLIP: chidx: buflen: */ + +# ifdef HAVE_USBHOST_TRACE_VERBOSE + + OTGFS_VTRACE2_CHANWAKEUP_IN, /* OTGFS IN Channel wake up with result */ + OTGFS_VTRACE2_CHANWAKEUP_OUT, /* OTGFS OUT Channel wake up with result */ + OTGFS_VTRACE2_CTRLIN, /* OTGFS CTRLIN */ + OTGFS_VTRACE2_CTRLOUT, /* OTGFS CTRLOUT */ + OTGFS_VTRACE2_INTRIN, /* OTGFS INTRIN */ + OTGFS_VTRACE2_INTROUT, /* OTGFS INTROUT */ + OTGFS_VTRACE2_BULKIN, /* OTGFS BULKIN */ + OTGFS_VTRACE2_BULKOUT, /* OTGFS BULKOUT */ + OTGFS_VTRACE2_ISOCIN, /* OTGFS ISOCIN */ + OTGFS_VTRACE2_ISOCOUT, /* OTGFS ISOCOUT */ + OTGFS_VTRACE2_STARTTRANSFER, /* OTGFS EP buflen */ + OTGFS_VTRACE2_CHANCONF_CTRL_IN, + OTGFS_VTRACE2_CHANCONF_CTRL_OUT, + OTGFS_VTRACE2_CHANCONF_INTR_IN, + OTGFS_VTRACE2_CHANCONF_INTR_OUT, + OTGFS_VTRACE2_CHANCONF_BULK_IN, + OTGFS_VTRACE2_CHANCONF_BULK_OUT, + OTGFS_VTRACE2_CHANCONF_ISOC_IN, + OTGFS_VTRACE2_CHANCONF_ISOC_OUT, + OTGFS_VTRACE2_CHANHALT, /* Channel halted. chidx: , reason: */ + +# endif +#endif + + __TRACE2_NSTRINGS /* Total number of enumeration values */ +}; + +# define TRACE1_FIRST ((int)__TRACE1_BASEVALUE + 1) +# define TRACE1_INDEX(id) ((int)(id) - TRACE1_FIRST) +# define TRACE1_NSTRINGS TRACE1_INDEX(__TRACE1_NSTRINGS) + +# define TRACE2_FIRST ((int)__TRACE1_NSTRINGS + 1) +# define TRACE2_INDEX(id) ((int)(id) - TRACE2_FIRST) +# define TRACE2_NSTRINGS TRACE2_INDEX(__TRACE2_NSTRINGS) + +#endif + /************************************************************************************ * Public Functions ************************************************************************************/ |