From 62b5054dfabcf9e26bf8e65db351db896c552e75 Mon Sep 17 00:00:00 2001
From: barthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>
Date: Sat, 17 Sep 2011 21:06:25 +0000
Subject: Shell. Added possibility to create statically allocated shell thread.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3331 35acf78f-673a-0410-8e92-d51de3d6d3f4
---
 os/various/shell.c | 26 ++++++++++++++++++++++++++
 os/various/shell.h |  2 ++
 2 files changed, 28 insertions(+)

diff --git a/os/various/shell.c b/os/various/shell.c
index 5f2fc760b..1fe03fc1e 100644
--- a/os/various/shell.c
+++ b/os/various/shell.c
@@ -220,6 +220,8 @@ void shellInit(void) {
 /**
  * @brief Spawns a new shell.
  *
+ * @pre   @p CH_USE_MALLOC_HEAP and @p CH_USE_DYNAMIC must be enabled.
+ *
  * @param[in] scp pointer to a @p ShellConfig object
  * @param[in] size size of the shell working area to be allocated
  * @param[in] prio the priority level for the new shell
@@ -227,10 +229,34 @@ void shellInit(void) {
  * @return A pointer to the shell thread.
  * @retval NULL thread creation failed because memory allocation.
  */
+#if CH_USE_HEAP && CH_USE_DYNAMIC
 Thread *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio) {
 
   return chThdCreateFromHeap(NULL, size, prio, shell_thread, (void *)scp);
 }
+#endif
+
+/**
+ * @brief Create statically allocated shell thread.
+ *
+ * @param[in] scp pointer to a @p ShellConfig object
+ * @param[in] wsp pointer to a working area dedicated to the shell thread stack
+ * @param[in] size size of the shell working area to be allocated
+ * @param[in] prio the priority level for the new shell
+ *
+ * @return A pointer to the shell thread.
+ */
+Thread *shellCreateStatic(const ShellConfig *scp, void *wsp,
+                          size_t size, tprio_t prio) {
+
+  return chThdCreateStatic(wsp, size, prio, shell_thread, (void *)scp);
+}
+
+
+
+
+
+
 
 /**
  * @brief Reads a whole line from the input channel.
diff --git a/os/various/shell.h b/os/various/shell.h
index 075d4e264..2946df947 100644
--- a/os/various/shell.h
+++ b/os/various/shell.h
@@ -80,6 +80,8 @@ extern "C" {
 #endif
   void shellInit(void);
   Thread *shellCreate(const ShellConfig *scp, size_t size, tprio_t prio);
+  Thread *shellCreateStatic(const ShellConfig *scp, void *wsp,
+                            size_t size, tprio_t prio);
   bool_t shellGetLine(BaseChannel *chp, char *line, unsigned size);
 #ifdef __cplusplus
 }
-- 
cgit v1.2.3