summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-15 14:37:37 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-15 14:37:37 +0000
commit327fb90cd335dc8d61d66c81487f73a5fc6f19a5 (patch)
tree7783ffd51c6a828b6b135733f489a14d45734f68
parent6132a9da939698fe9d5d3a7310d1287d5cb7a1a7 (diff)
downloadnuttx-327fb90cd335dc8d61d66c81487f73a5fc6f19a5.tar.gz
nuttx-327fb90cd335dc8d61d66c81487f73a5fc6f19a5.tar.bz2
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
-rw-r--r--NxWidgets/ChangeLog.txt2
-rw-r--r--NxWidgets/libnxwidgets/src/clabel.cxx2
-rw-r--r--nuttx/ChangeLog18
-rw-r--r--nuttx/Documentation/NuttxUserGuide.html188
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_otgfsdev.c139
-rw-r--r--nuttx/drivers/usbdev/Kconfig15
-rw-r--r--nuttx/drivers/usbdev/usbdev_trprintf.c40
-rw-r--r--nuttx/include/nuttx/arch.h38
-rw-r--r--nuttx/include/nuttx/usb/usbdev_trace.h51
-rw-r--r--nuttx/sched/Kconfig28
-rw-r--r--nuttx/sched/os_start.c6
11 files changed, 422 insertions, 105 deletions
diff --git a/NxWidgets/ChangeLog.txt b/NxWidgets/ChangeLog.txt
index 43347fcdb..dd3422dcc 100644
--- a/NxWidgets/ChangeLog.txt
+++ b/NxWidgets/ChangeLog.txt
@@ -278,4 +278,6 @@
action event. From Petteri Aimonen.
* NxWidgets/tools/bitmap_converter.py: Fix bitmap_converter.py so that
it works with indexed input images.
+* NxWidgets::CLabel: Fix backward conditional compilation in the
+ "flicker free" logic.
diff --git a/NxWidgets/libnxwidgets/src/clabel.cxx b/NxWidgets/libnxwidgets/src/clabel.cxx
index be4fe902d..376d2ce8f 100644
--- a/NxWidgets/libnxwidgets/src/clabel.cxx
+++ b/NxWidgets/libnxwidgets/src/clabel.cxx
@@ -303,7 +303,7 @@ void CLabel::drawContents(CGraphicsPort *port)
// Draw the background (excluding the border)
-#ifdef CONFIG_NXWIDGETS_FLICKERFREE
+#ifndef CONFIG_NXWIDGETS_FLICKERFREE
port->drawFilledRect(rect.getX(), rect.getY(),
rect.getWidth(), rect.getHeight(), backColor);
#endif
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 0b23207da..b15cac83e 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -4178,3 +4178,21 @@
* configs/stm32f3discovery/nsh/defconfig: Disable SPI. It is nto
used.
* drivers/mtd/sst39vf: Add a driver for the SST29VF NOR FLASH parts.
+ * sched/os_start.c: Add an additional call-out to support board-
+ specific driver initialization during the start phase: If
+ CONFIG_BOARD_INITIALIZE is defined, then an additioinal
+ initialization function called board_initialize() will be called
+ just after up_initialize() is called and just before the initial
+ application is started.
+ * arch/arm/src/stm32/stm32_otgfsdev.c, drivers/usbdev/usbdev_trprintf.c,
+ and include/nuttx/usb/usbdev_trace.h: Add logic to support decoding
+ of device-specific trace events to make the trace ouput more readable.
+ From Petteri Aimonen.
+ * arch/arm/src/stm32/stm32_otgfsdev.c: Need to manually set CNAK in
+ the case where we are waiting for a SETUP command with DATA. Otherwise,
+ the core may NAK further transactions. From Petteri Aimonen.
+ * arch/arm/src/stm32/stm32_otgfsdev.c: Add logic to prevent premature
+ to IDLE state. This change (plus the previous) was necessary to get
+ the CDC/ACM driver working the certain STM32 F4 hardware (but not others).
+ These changes appear to prevent certain race conditions that may or may
+ not cause USB problems. From Petteri Aimonen.
diff --git a/nuttx/Documentation/NuttxUserGuide.html b/nuttx/Documentation/NuttxUserGuide.html
index 3df2dfa9d..a12e61335 100644
--- a/nuttx/Documentation/NuttxUserGuide.html
+++ b/nuttx/Documentation/NuttxUserGuide.html
@@ -13,7 +13,7 @@
<h1><big><font color="#3c34ec"><i>NuttX Operating System<p>User's Manual</i></font></big></h1>
<p><small>by</small></p>
<p>Gregory Nutt<p>
- <p>Last Updated: February 5, 2013</p>
+ <p>Last Updated: February 13, 2013</p>
</td>
</tr>
</table>
@@ -1999,8 +1999,22 @@ priority of the calling task is returned.
<li><a href="#waitid">2.3.5 waitid</a></li>
<li><a href="#wait">2.3.6 wait</a></li>
</ul>
+ <li>
+ <p>
+ <b>Task Exit Hooks</b>.
+ <code>atexit()</code> and <code>on_exit()</code> may be use to register callback functions that are executed when a <i>task group</i> terminates.
+ A task group is the functional analog of a process:
+ It is a group that consists of the main task thread and of all of the pthreads created by the main task thread or any of the other pthreads within the task broup.
+ Members of a task group share certain resources such as environment variables, file descriptors, <code>FILE</code> streams, sockets, pthread keys and open message queues.
+ </p>
+ <blockquote><small>
+ <b>NOTE:</b>
+ Behavior of features related to <i>task group</i>s depend of NuttX configuration settings.
+ See the discussion of &quot;Parent and Child Tasks,&quot; below.
+ See also the <a href="http://www.nuttx.org/doku.php?id=wiki:nxinternal:nxtasking">NuttX Threading Wiki</a> page and the <a href="http://www.nuttx.org/doku.php?id=wiki:nxinternal:tasksnthreads">Tasks vs. Threads FAQ</a> for additional information on tasks and threads in NuttX.
+ </small></blockquote>
<p>
- <code>atexit()</code> and <code>on_exit()</code> may be use to register callback functions that are executed when a task exits.
+ A <i>task group</i> terminates when the last thread within the group exits.
</p>
<ul>
<li><a href="#atexit">2.3.7 atexit</a></li>
@@ -4649,12 +4663,14 @@ interface of the same name.
NuttX supports both tasks and pthreads.
The primary difference between tasks and pthreads is the tasks are much more independent.
Tasks can create pthreads and those pthreads will share the resources of the task.
- The main task and its children pthreads together are referred as a "task group."
+ The main task and its children pthreads together are referred as a <i>task group</i>.
A task group is used in NuttX to emulate a POSIX <i>process</i>.
</p>
-<p>
+<blockquote><small>
+ <b>NOTE:</b>
+ Behavior of features related to <i>task group</i>s depend of NuttX configuration settings.
See the <a href="http://www.nuttx.org/doku.php?id=wiki:nxinternal:nxtasking">NuttX Threading Wiki</a> page and the <a href="http://www.nuttx.org/doku.php?id=wiki:nxinternal:tasksnthreads">Tasks vs. Threads FAQ</a> for additional information on tasks and threads in NuttX.
-</p>
+</small></blockquote>
<p>
<b>Signalling Multi-threaded Task Groups</b>.
The behavior of signals in the multi-thread task group is complex.
@@ -5326,68 +5342,114 @@ be sent.
<p>
NuttX does not support <i>processes</i> in the way that, say, Linux does.
NuttX only supports simple threads or tasks running within the same address space.
- For the most part, threads and tasks are interchangeable and differ primarily
- only in such things as the inheritance of file descriptors.
- Basically, threads are initialized and uninitialized differently and share a
- few more resources than tasks.
+ However, NuttX does support the concept of a <i>task group</i>.
+ A task group is the functional analog of a process:
+ It is a group that consists of the main task thread and of all of the pthreads created by the main thread or any of the other pthreads within the task broup.
+ Members of a task group share certain resources such as environment variables, file descriptors, <code>FILE</code> streams, sockets, pthread keys and open message queues.
+</p>
+<blockquote><small>
+ <b>NOTE:</b>
+ Behavior of features related to <i>task group</i>s depend of NuttX configuration settings.
+ See the <a href="http://www.nuttx.org/doku.php?id=wiki:nxinternal:nxtasking">NuttX Threading Wiki</a> page and the <a href="http://www.nuttx.org/doku.php?id=wiki:nxinternal:tasksnthreads">Tasks vs. Threads FAQ</a> for additional information on tasks and threads in NuttX.
+</small></blockquote>
<p>
The following pthread interfaces are supported in some form by NuttX:
</p>
<ul>
- <li><a href="#pthreadattrinit">2.9.1 pthread_attr_init</a></li>
- <li><a href="#pthreadattrdestroy">2.9.2 pthread_attr_destroy</a></li>
- <li><a href="#pthreadattrsetschedpolity">2.9.3 pthread_attr_setschedpolicy</a></li>
- <li><a href="#pthreadattrgetschedpolicy">2.9.4 pthread_attr_getschedpolicy</a></li>
- <li><a href="#pthreadattrsetschedparam">2.9.5 pthread_attr_setschedparam</a></li>
- <li><a href="#pthreadattrgetschedparam">2.9.6 pthread_attr_getschedparam</a></li>
- <li><a href="#pthreadattrsetinheritsched">2.9.7 pthread_attr_setinheritsched</a></li>
- <li><a href="#pthreadattrgetinheritsched">2.9.8 pthread_attr_getinheritsched</a></li>
- <li><a href="#pthreadattrsetstacksize">2.9.9 pthread_attr_setstacksize</a></li>
- <li><a href="#pthreadattrgetstacksize">2.9.10 pthread_attr_getstacksize</a></li>
- <li><a href="#pthreadcreate">2.9.11 pthread_create</a></li>
- <li><a href="#pthreaddetach">2.9.12 pthread_detach</a></li>
- <li><a href="#pthreadexit">2.9.13 pthread_exit</a></li>
- <li><a href="#pthreadcancel">2.9.14 pthread_cancel</a></li>
- <li><a href="#pthreadsetcancelstate">2.9.15 pthread_setcancelstate</a></li>
- <li><a href="#pthreadtestcancelstate">2.9.16 pthread_testcancelstate</a></li>
- <li><a href="#pthreadjoin">2.9.17 pthread_join</a></li>
- <li><a href="#pthreadyield">2.9.18 pthread_yield</a></li>
- <li><a href="#pthreadself">2.9.19 pthread_self</a></li>
- <li><a href="#pthreadgetschedparam">2.9.20 pthread_getschedparam</a></li>
- <li><a href="#pthreadsetschedparam">2.9.21 pthread_setschedparam</a></li>
- <li><a href="#pthreadkeycreate">2.9.22 pthread_key_create</a></li>
- <li><a href="#pthreadsetspecific">2.9.23 pthread_setspecific</a></li>
- <li><a href="#pthreadgetspecific">2.9.24 pthread_getspecific</a></li>
- <li><a href="#pthreadkeydelete">2.9.25 pthread_key_delete</a></li>
- <li><a href="#pthreadmutexattrinit">2.9.26 pthread_mutexattr_init</a></li>
- <li><a href="#pthreadmutexattrdestroy">2.9.27 pthread_mutexattr_destroy</a></li>
- <li><a href="#pthreadmutexattrgetpshared">2.9.28 pthread_mutexattr_getpshared</a></li>
- <li><a href="#pthreadmutexattrsetpshared">2.9.29 pthread_mutexattr_setpshared</a></li>
- <li><a href="#pthreadmutexattrgettype">2.9.30 pthread_mutexattr_gettype</a></li>
- <li><a href="#pthreadmutexattrsettype">2.9.31 pthread_mutexattr_settype</a></li>
- <li><a href="#pthreadmutexinit">2.9.32 pthread_mutex_init</a></li>
- <li><a href="#pthreadmutexdestrory">2.9.33 pthread_mutex_destroy</a></li>
- <li><a href="#pthreadmutexlock">2.9.34 pthread_mutex_lock</a></li>
- <li><a href="#pthreadmutextrylock">2.9.35 pthread_mutex_trylock</a></li>
- <li><a href="#pthreadmutexunlock">2.9.36 pthread_mutex_unlock</a></li>
- <li><a href="#pthreadconaddrinit">2.9.37 pthread_condattr_init</a></li>
- <li><a href="#pthreadocndattrdestroy">2.9.38 pthread_condattr_destroy</a></li>
- <li><a href="#pthreadcondinit">2.9.39 pthread_cond_init</a></li>
- <li><a href="#pthreadconddestroy">2.9.40 pthread_cond_destroy</a></li>
- <li><a href="#pthreadcondbroadcast">2.9.41 pthread_cond_broadcast</a></li>
- <li><a href="#pthreadcondsignal">2.9.42 pthread_cond_signal</a></li>
- <li><a href="#pthreadcondwait">2.9.43 pthread_cond_wait</a></li>
- <li><a href="#pthreadcondtimedwait">2.9.44 pthread_cond_timedwait</a></li>
- <li><a href="#pthreadbarrierattrinit">2.9.45 pthread_barrierattr_init</a></li>
- <li><a href="#pthreadbarrierattrdestroy">2.9.46 pthread_barrierattr_destroy</a></li>
- <li><a href="#pthreadbarrierattrsetpshared">2.9.47 pthread_barrierattr_setpshared</a></li>
- <li><a href="#pthreadbarrierattrgetpshared">2.9.48 pthread_barrierattr_getpshared</a></li>
- <li><a href="#pthreadbarrierinit">2.9.49 pthread_barrier_init</a></li>
- <li><a href="#pthreadbarrierdestroy">2.9.50 pthread_barrier_destroy</a></li>
- <li><a href="#pthreadbarrierwait">2.9.51 pthread_barrier_wait</a></li>
- <li><a href="#pthreadonce">2.9.52 pthread_once</a></li>
- <li><a href="#pthreadkill">2.9.53 pthread_kill</a></li>
- <li><a href="#pthreadsigmask">2.9.54 pthread_sigmask</a></li>
+ <p>
+ <b>pthread control interfaces</b>.
+ Interfaces that allow you to create and manage pthreads.
+ </p>
+ <ul>
+ <li><a href="#pthreadattrinit">2.9.1 pthread_attr_init</a></li>
+ <li><a href="#pthreadattrdestroy">2.9.2 pthread_attr_destroy</a></li>
+ <li><a href="#pthreadattrsetschedpolity">2.9.3 pthread_attr_setschedpolicy</a></li>
+ <li><a href="#pthreadattrgetschedpolicy">2.9.4 pthread_attr_getschedpolicy</a></li>
+ <li><a href="#pthreadattrsetschedparam">2.9.5 pthread_attr_setschedparam</a></li>
+ <li><a href="#pthreadattrgetschedparam">2.9.6 pthread_attr_getschedparam</a></li>
+ <li><a href="#pthreadattrsetinheritsched">2.9.7 pthread_attr_setinheritsched</a></li>
+ <li><a href="#pthreadattrgetinheritsched">2.9.8 pthread_attr_getinheritsched</a></li>
+ <li><a href="#pthreadattrsetstacksize">2.9.9 pthread_attr_setstacksize</a></li>
+ <li><a href="#pthreadattrgetstacksize">2.9.10 pthread_attr_getstacksize</a></li>
+ <li><a href="#pthreadcreate">2.9.11 pthread_create</a></li>
+ <li><a href="#pthreaddetach">2.9.12 pthread_detach</a></li>
+ <li><a href="#pthreadexit">2.9.13 pthread_exit</a></li>
+ <li><a href="#pthreadcancel">2.9.14 pthread_cancel</a></li>
+ <li><a href="#pthreadsetcancelstate">2.9.15 pthread_setcancelstate</a></li>
+ <li><a href="#pthreadtestcancelstate">2.9.16 pthread_testcancelstate</a></li>
+ <li><a href="#pthreadjoin">2.9.17 pthread_join</a></li>
+ <li><a href="#pthreadyield">2.9.18 pthread_yield</a></li>
+ <li><a href="#pthreadself">2.9.19 pthread_self</a></li>
+ <li><a href="#pthreadgetschedparam">2.9.20 pthread_getschedparam</a></li>
+ <li><a href="#pthreadsetschedparam">2.9.21 pthread_setschedparam</a></li>
+ </ul>
+ <p>
+ <b>Thread Specific Data</b>.
+ These interfaces can be used to create pthread <i>keys</i> and then to access thread-specific data using these keys.
+ Each <i>task group</i> has its own set of pthread keys.
+ NOTES: (1) pthread keys create in one <i>task group</i> are not accessible in other task groups.
+ (2) The main task thread does not had thread-specific data.
+ </p>
+ <ul>
+ <li><a href="#pthreadkeycreate">2.9.22 pthread_key_create</a></li>
+ <li><a href="#pthreadsetspecific">2.9.23 pthread_setspecific</a></li>
+ <li><a href="#pthreadgetspecific">2.9.24 pthread_getspecific</a></li>
+ <li><a href="#pthreadkeydelete">2.9.25 pthread_key_delete</a></li>
+ </ul>
+ <p>
+ <b>pthread Mutexes</b>.
+ </p>
+ <ul>
+ <li><a href="#pthreadmutexattrinit">2.9.26 pthread_mutexattr_init</a></li>
+ <li><a href="#pthreadmutexattrdestroy">2.9.27 pthread_mutexattr_destroy</a></li>
+ <li><a href="#pthreadmutexattrgetpshared">2.9.28 pthread_mutexattr_getpshared</a></li>
+ <li><a href="#pthreadmutexattrsetpshared">2.9.29 pthread_mutexattr_setpshared</a></li>
+ <li><a href="#pthreadmutexattrgettype">2.9.30 pthread_mutexattr_gettype</a></li>
+ <li><a href="#pthreadmutexattrsettype">2.9.31 pthread_mutexattr_settype</a></li>
+ <li><a href="#pthreadmutexinit">2.9.32 pthread_mutex_init</a></li>
+ <li><a href="#pthreadmutexdestrory">2.9.33 pthread_mutex_destroy</a></li>
+ <li><a href="#pthreadmutexlock">2.9.34 pthread_mutex_lock</a></li>
+ <li><a href="#pthreadmutextrylock">2.9.35 pthread_mutex_trylock</a></li>
+ <li><a href="#pthreadmutexunlock">2.9.36 pthread_mutex_unlock</a></li>
+ </ul>
+ <p>
+ <b>Condition Variables</b>.
+ </p>
+ <ul>
+ <li><a href="#pthreadconaddrinit">2.9.37 pthread_condattr_init</a></li>
+ <li><a href="#pthreadocndattrdestroy">2.9.38 pthread_condattr_destroy</a></li>
+ <li><a href="#pthreadcondinit">2.9.39 pthread_cond_init</a></li>
+ <li><a href="#pthreadconddestroy">2.9.40 pthread_cond_destroy</a></li>
+ <li><a href="#pthreadcondbroadcast">2.9.41 pthread_cond_broadcast</a></li>
+ <li><a href="#pthreadcondsignal">2.9.42 pthread_cond_signal</a></li>
+ <li><a href="#pthreadcondwait">2.9.43 pthread_cond_wait</a></li>
+ <li><a href="#pthreadcondtimedwait">2.9.44 pthread_cond_timedwait</a></li>
+ </ul>
+ <p>
+ <b>Barriers</b>.
+ </p>
+ <ul>
+ <li><a href="#pthreadbarrierattrinit">2.9.45 pthread_barrierattr_init</a></li>
+ <li><a href="#pthreadbarrierattrdestroy">2.9.46 pthread_barrierattr_destroy</a></li>
+ <li><a href="#pthreadbarrierattrsetpshared">2.9.47 pthread_barrierattr_setpshared</a></li>
+ <li><a href="#pthreadbarrierattrgetpshared">2.9.48 pthread_barrierattr_getpshared</a></li>
+ <li><a href="#pthreadbarrierinit">2.9.49 pthread_barrier_init</a></li>
+ <li><a href="#pthreadbarrierdestroy">2.9.50 pthread_barrier_destroy</a></li>
+ <li><a href="#pthreadbarrierwait">2.9.51 pthread_barrier_wait</a></li>
+ </ul>
+ <p>
+ <b>Initialization</b>.
+ </p>
+ <ul>
+ <li><a href="#pthreadonce">2.9.52 pthread_once</a></li>
+ </ul>
+ <p>
+ <b>Signals</b>.
+ </p>
+ <ul>
+ <li><a href="#pthreadkill">2.9.53 pthread_kill</a></li>
+ <li><a href="#pthreadsigmask">2.9.54 pthread_sigmask</a></li>
+ </ul>
</ul>
<p>
No support for the following pthread interfaces is provided by NuttX:
diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c
index bcce3ce60..1496dc5a8 100644
--- a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c
+++ b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c
@@ -679,6 +679,99 @@ static const struct usbdev_ops_s g_devops =
.pullup = stm32_pullup,
};
+/* Device error strings that may be enabled for more desciptive USB trace
+ * output.
+ */
+
+#ifdef CONFIG_USBDEV_TRACE_STRINGS
+const struct trace_msg_t g_usb_trace_strings_deverror[] =
+{
+ TRACE_STR(STM32_TRACEERR_ALLOCFAIL ),
+ TRACE_STR(STM32_TRACEERR_BADCLEARFEATURE ),
+ TRACE_STR(STM32_TRACEERR_BADDEVGETSTATUS ),
+ TRACE_STR(STM32_TRACEERR_BADEPNO ),
+ TRACE_STR(STM32_TRACEERR_BADEPGETSTATUS ),
+ TRACE_STR(STM32_TRACEERR_BADGETCONFIG ),
+ TRACE_STR(STM32_TRACEERR_BADGETSETDESC ),
+ TRACE_STR(STM32_TRACEERR_BADGETSTATUS ),
+ TRACE_STR(STM32_TRACEERR_BADSETADDRESS ),
+ TRACE_STR(STM32_TRACEERR_BADSETCONFIG ),
+ TRACE_STR(STM32_TRACEERR_BADSETFEATURE ),
+ TRACE_STR(STM32_TRACEERR_BADTESTMODE ),
+ TRACE_STR(STM32_TRACEERR_BINDFAILED ),
+ TRACE_STR(STM32_TRACEERR_DISPATCHSTALL ),
+ TRACE_STR(STM32_TRACEERR_DRIVER ),
+ TRACE_STR(STM32_TRACEERR_DRIVERREGISTERED),
+ TRACE_STR(STM32_TRACEERR_EP0NOSETUP ),
+ TRACE_STR(STM32_TRACEERR_EP0SETUPSTALLED ),
+ TRACE_STR(STM32_TRACEERR_EPINNULLPACKET ),
+ TRACE_STR(STM32_TRACEERR_EPOUTNULLPACKET ),
+ TRACE_STR(STM32_TRACEERR_INVALIDCTRLREQ ),
+ TRACE_STR(STM32_TRACEERR_INVALIDPARMS ),
+ TRACE_STR(STM32_TRACEERR_IRQREGISTRATION ),
+ TRACE_STR(STM32_TRACEERR_NOEP ),
+ TRACE_STR(STM32_TRACEERR_NOTCONFIGURED ),
+ TRACE_STR(STM32_TRACEERR_EPOUTQEMPTY ),
+ TRACE_STR(STM32_TRACEERR_EPINREQEMPTY ),
+ TRACE_STR(STM32_TRACEERR_NOOUTSETUP ),
+ TRACE_STR(STM32_TRACEERR_POLLTIMEOUT ),
+ TRACE_STR_END
+};
+#endif
+
+/* Interrupt event strings that may be enabled for more desciptive USB trace
+ * output.
+ */
+
+#ifdef CONFIG_USBDEV_TRACE_STRINGS
+const struct trace_msg_t g_usb_trace_strings_intdecode[] =
+{
+ TRACE_STR(STM32_TRACEINTID_USB ),
+ TRACE_STR(STM32_TRACEINTID_INTPENDING ),
+ TRACE_STR(STM32_TRACEINTID_EPOUT ),
+ TRACE_STR(STM32_TRACEINTID_EPIN ),
+ TRACE_STR(STM32_TRACEINTID_MISMATCH ),
+ TRACE_STR(STM32_TRACEINTID_WAKEUP ),
+ TRACE_STR(STM32_TRACEINTID_SUSPEND ),
+ TRACE_STR(STM32_TRACEINTID_SOF ),
+ TRACE_STR(STM32_TRACEINTID_RXFIFO ),
+ TRACE_STR(STM32_TRACEINTID_DEVRESET ),
+ TRACE_STR(STM32_TRACEINTID_ENUMDNE ),
+ TRACE_STR(STM32_TRACEINTID_IISOIXFR ),
+ TRACE_STR(STM32_TRACEINTID_IISOOXFR ),
+ TRACE_STR(STM32_TRACEINTID_SRQ ),
+ TRACE_STR(STM32_TRACEINTID_OTG ),
+ TRACE_STR(STM32_TRACEINTID_EPOUT_XFRC ),
+ TRACE_STR(STM32_TRACEINTID_EPOUT_EPDISD),
+ TRACE_STR(STM32_TRACEINTID_EPOUT_SETUP ),
+ TRACE_STR(STM32_TRACEINTID_DISPATCH ),
+ TRACE_STR(STM32_TRACEINTID_GETSTATUS ),
+ TRACE_STR(STM32_TRACEINTID_EPGETSTATUS ),
+ TRACE_STR(STM32_TRACEINTID_DEVGETSTATUS),
+ TRACE_STR(STM32_TRACEINTID_IFGETSTATUS ),
+ TRACE_STR(STM32_TRACEINTID_CLEARFEATURE),
+ TRACE_STR(STM32_TRACEINTID_SETFEATURE ),
+ TRACE_STR(STM32_TRACEINTID_SETADDRESS ),
+ TRACE_STR(STM32_TRACEINTID_GETSETDESC ),
+ TRACE_STR(STM32_TRACEINTID_GETCONFIG ),
+ TRACE_STR(STM32_TRACEINTID_SETCONFIG ),
+ TRACE_STR(STM32_TRACEINTID_GETSETIF ),
+ TRACE_STR(STM32_TRACEINTID_SYNCHFRAME ),
+ TRACE_STR(STM32_TRACEINTID_EPIN_XFRC ),
+ TRACE_STR(STM32_TRACEINTID_EPIN_TOC ),
+ TRACE_STR(STM32_TRACEINTID_EPIN_ITTXFE ),
+ TRACE_STR(STM32_TRACEINTID_EPIN_EPDISD ),
+ TRACE_STR(STM32_TRACEINTID_EPIN_TXFE ),
+ TRACE_STR(STM32_TRACEINTID_EPIN_EMPWAIT),
+ TRACE_STR(STM32_TRACEINTID_OUTNAK ),
+ TRACE_STR(STM32_TRACEINTID_OUTRECVD ),
+ TRACE_STR(STM32_TRACEINTID_OUTDONE ),
+ TRACE_STR(STM32_TRACEINTID_SETUPDONE ),
+ TRACE_STR(STM32_TRACEINTID_SETUPRECVD ),
+ TRACE_STR_END
+};
+#endif
+
/*******************************************************************************
* Public Data
*******************************************************************************/
@@ -1142,7 +1235,7 @@ static void stm32_epin_request(FAR struct stm32_usbdev_s *priv,
/* Add one more packet to the TxFIFO. We will wait for the transfer
* complete event before we add the next packet (or part of a packet
* to the TxFIFO).
- *
+ *
* The documentation says that we can can multiple packets to the TxFIFO,
* but it seems that we need to get the transfer complete event before
* we can add the next (or maybe I have got something wrong?)
@@ -2459,16 +2552,16 @@ static inline void stm32_epout(FAR struct stm32_usbdev_s *priv, uint8_t epno)
/* Continue processing data from the EP0 OUT request queue */
stm32_epout_complete(priv, privep);
- }
- /* If we are not actively processing an OUT request, then we
- * need to setup to receive the next control request.
- */
+ /* If we are not actively processing an OUT request, then we
+ * need to setup to receive the next control request.
+ */
- if (!privep->active)
- {
- stm32_ep0out_ctrlsetup(priv);
- priv->ep0state = EP0STATE_IDLE;
+ if (!privep->active)
+ {
+ stm32_ep0out_ctrlsetup(priv);
+ priv->ep0state = EP0STATE_IDLE;
+ }
}
}
@@ -2626,16 +2719,16 @@ static inline void stm32_epin(FAR struct stm32_usbdev_s *priv, uint8_t epno)
/* Continue processing data from the EP0 OUT request queue */
stm32_epin_request(priv, privep);
- }
- /* If we are not actively processing an OUT request, then we
- * need to setup to receive the next control request.
- */
+ /* If we are not actively processing an OUT request, then we
+ * need to setup to receive the next control request.
+ */
- if (!privep->active)
- {
- stm32_ep0out_ctrlsetup(priv);
- priv->ep0state = EP0STATE_IDLE;
+ if (!privep->active)
+ {
+ stm32_ep0out_ctrlsetup(priv);
+ priv->ep0state = EP0STATE_IDLE;
+ }
}
/* Test mode is another special case */
@@ -2754,7 +2847,7 @@ static inline void stm32_epin_interrupt(FAR struct stm32_usbdev_s *priv)
* interrupt here; it will be re-enabled if there is still
* insufficient space in the TxFIFO.
*/
-
+
empty &= ~OTGFS_DIEPEMPMSK(epno);
stm32_putreg(empty, STM32_OTGFS_DIEPEMPMSK);
stm32_putreg(OTGFS_DIEPINT_XFRC, STM32_OTGFS_DIEPINT(epno));
@@ -3063,6 +3156,12 @@ static inline void stm32_rxinterrupt(FAR struct stm32_usbdev_s *priv)
datlen = GETUINT16(priv->ctrlreq.len);
if (USB_REQ_ISOUT(priv->ctrlreq.type) && datlen > 0)
{
+ /* Clear NAKSTS so that we can receive the data */
+
+ regval = stm32_getreg(STM32_OTGFS_DOEPCTL0);
+ regval |= OTGFS_DOEPCTL0_CNAK;
+ stm32_putreg(regval, STM32_OTGFS_DOEPCTL0);
+
/* Wait for the data phase. */
priv->ep0state = EP0STATE_SETUP_OUT;
@@ -3654,7 +3753,7 @@ static int stm32_epout_configure(FAR struct stm32_ep_s *privep, uint8_t eptype,
{
regval |= OTGFS_DOEPCTL_CNAK;
}
-
+
regval &= ~(OTGFS_DOEPCTL_MPSIZ_MASK | OTGFS_DOEPCTL_EPTYP_MASK);
regval |= mpsiz;
regval |= (eptype << OTGFS_DOEPCTL_EPTYP_SHIFT);
@@ -3750,7 +3849,7 @@ static int stm32_epin_configure(FAR struct stm32_ep_s *privep, uint8_t eptype,
{
regval |= OTGFS_DIEPCTL_CNAK;
}
-
+
regval &= ~(OTGFS_DIEPCTL_MPSIZ_MASK | OTGFS_DIEPCTL_EPTYP_MASK | OTGFS_DIEPCTL_TXFNUM_MASK);
regval |= mpsiz;
regval |= (eptype << OTGFS_DIEPCTL_EPTYP_SHIFT);
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 */
diff --git a/nuttx/include/nuttx/arch.h b/nuttx/include/nuttx/arch.h
index c86b66ed1..2afe7166f 100644
--- a/nuttx/include/nuttx/arch.h
+++ b/nuttx/include/nuttx/arch.h
@@ -81,25 +81,39 @@ extern "C"
* Name: up_initialize
*
* Description:
- * up_initialize will be called once during OS
- * initialization after the basic OS services have been
- * initialized. The architecture specific details of
- * initializing the OS will be handled here. Such things as
- * setting up interrupt service routines, starting the
- * clock, and registering device drivers are some of the
- * things that are different for each processor and hardware
- * platform.
+ * up_initialize will be called once during OS initialization after the
+ * basic OS services have been initialized. The architecture specific
+ * details of initializing the OS will be handled here. Such things as
+ * setting up interrupt service routines, starting the clock, and
+ * registering device drivers are some of the things that are different
+ * for each processor and hardware platform.
*
- * up_initialize is called after the OS initialized but
- * before the init process has been started and before the
- * libraries have been initialized. OS services and driver
- * services are available.
+ * up_initialize is called after the OS initialized but before the initial
+ * application has been started and before the libraries have been
+ * initialized. OS services and driver services are available.
*
****************************************************************************/
void up_initialize(void);
/****************************************************************************
+ * Name: board_initialize
+ *
+ * Description:
+ * If CONFIG_BOARD_INITIALIZE is selected, then an additional
+ * initialization call will be performed in the boot-up sequence to a
+ * function called board_initialize(). board_initialize() will be
+ * called immediately after up_intiialize() is called and just before the
+ * initial application is started. This additional initialization phase
+ * may be used, for example, to initialize board-specific device drivers.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARD_INITIALIZE
+void board_initialize(void);
+#endif
+
+/****************************************************************************
* Name: up_idle
*
* Description:
diff --git a/nuttx/include/nuttx/usb/usbdev_trace.h b/nuttx/include/nuttx/usb/usbdev_trace.h
index 860f48983..b6f0ac2a3 100644
--- a/nuttx/include/nuttx/usb/usbdev_trace.h
+++ b/nuttx/include/nuttx/usb/usbdev_trace.h
@@ -1,7 +1,7 @@
/****************************************************************************
* include/nuttx/usb/usbdev_trace.h
*
- * Copyright (C) 2008, 2009-2010, 2012 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2008, 2009-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
@@ -174,6 +174,14 @@
#define TRACE_CLSERROR(id) TRACE_EVENT(TRACE_CLSERROR_ID, id)
+/* Event string descriptions ************************************************/
+/* Macros for defining the string arrays for display of the traces. */
+
+#ifdef CONFIG_USBDEV_TRACE_STRINGS
+# define TRACE_STR(id) {id, #id}
+# define TRACE_STR_END {0, NULL}
+#endif
+
/* USB Serial driver class events *******************************************/
/* Used by both the CDC/ACM and the PL2303 serial class drivers */
/* UART interface API calls */
@@ -398,6 +406,18 @@ struct usbtrace_s
uint16_t value;
};
+/* Describes on element of a string string for decoding of device-specific
+ * trace events.
+ */
+
+#ifdef CONFIG_USBDEV_TRACE_STRINGS
+struct trace_msg_t
+{
+ int id;
+ const char *str;
+};
+#endif
+
/* Enumeration callback function signature */
typedef int (*trace_callback_t)(struct usbtrace_s *trace, void *arg);
@@ -413,17 +433,32 @@ typedef uint16_t usbtrace_idset_t;
typedef int (*trprintf_t)(const char *fmt, ...);
/****************************************************************************
- * Public Function Prototypes
+ * Public Data
****************************************************************************/
-
+
#undef EXTERN
#if defined(__cplusplus)
# define EXTERN extern "C"
-extern "C" {
+extern "C"
+{
#else
# define EXTERN extern
#endif
+/* If CONFIG_USBDEV_TRACE_STRINGS is defined, then the USB device controller
+ * driver must provide these strings to support decoding of device-specific
+ * trace events.
+ */
+
+#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
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
/*******************************************************************************
* Name: usbtrace_enable
*
@@ -443,7 +478,7 @@ extern "C" {
*******************************************************************************/
#if defined(CONFIG_USBDEV_TRACE) || (defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_USB))
-EXTERN usbtrace_idset_t usbtrace_enable(usbtrace_idset_t idset);
+usbtrace_idset_t usbtrace_enable(usbtrace_idset_t idset);
#else
# define usbtrace_enable(idset)
#endif
@@ -460,7 +495,7 @@ EXTERN usbtrace_idset_t usbtrace_enable(usbtrace_idset_t idset);
*******************************************************************************/
#if defined(CONFIG_USBDEV_TRACE) || (defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_USB))
-EXTERN void usbtrace(uint16_t event, uint16_t value);
+void usbtrace(uint16_t event, uint16_t value);
#else
# define usbtrace(event, value)
#endif
@@ -477,7 +512,7 @@ EXTERN void usbtrace(uint16_t event, uint16_t value);
*******************************************************************************/
#ifdef CONFIG_USBDEV_TRACE
-EXTERN int usbtrace_enumerate(trace_callback_t callback, void *arg);
+int usbtrace_enumerate(trace_callback_t callback, void *arg);
#else
# define usbtrace_enumerate(event)
#endif
@@ -490,7 +525,7 @@ EXTERN int usbtrace_enumerate(trace_callback_t callback, void *arg);
*
*******************************************************************************/
-EXTERN void usbtrace_trprintf(trprintf_t trprintf, uint16_t event, uint16_t value);
+void usbtrace_trprintf(trprintf_t trprintf, uint16_t event, uint16_t value);
#undef EXTERN
#if defined(__cplusplus)
diff --git a/nuttx/sched/Kconfig b/nuttx/sched/Kconfig
index f9ba37cea..61900f498 100644
--- a/nuttx/sched/Kconfig
+++ b/nuttx/sched/Kconfig
@@ -3,6 +3,34 @@
# see misc/tools/kconfig-language.txt.
#
+config BOARD_INITIALIZE
+ bool "Custom board/driver initialization"
+ default n
+ ---help---
+ By default, there are three points in time where you can insert
+ custom initialization logic:
+
+ 1) <arch>_boardinitialize(): This function is used only for
+ initialize of very low-level things like configuration of
+ GPIO pins, power setting. The OS has not been initialized
+ at this point, so you cannot allocate memory or initialize
+ device drivers at this phase.
+
+ 2) The next level of initialization is performed by a call to
+ up_initialize() (in arch/<arch>/src/common/up_initialize.c).
+ The OS has been initialized at this point and it is okay to
+ initialize drivers in this phase.
+
+ 3) And, finally, when the user application code starts.
+
+ If BOARD_INITIALIZE is selected, then an additional initialization
+ call will be performed in the boot-up sequence to a function
+ called board_initialize(). board_initialize() will be
+ call between phases 2) and 3) above, immediately after
+ up_initialize() is called. This additional initialization
+ phase may be used, for example, to initialize board-specific
+ device drivers.
+
config MSEC_PER_TICK
int "Milliseconds per system timer tick"
default 10
diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c
index 86b40bfbb..2e9991547 100644
--- a/nuttx/sched/os_start.c
+++ b/nuttx/sched/os_start.c
@@ -434,6 +434,12 @@ void os_start(void)
up_initialize();
+ /* Perform any special board-specific initialization, if so configured. */
+
+#ifdef CONFIG_BOARD_INITIALIZE
+ board_initialize();
+#endif
+
/* Initialize the C libraries (if included in the link). This
* is done last because the libraries may depend on the above.
*/