aboutsummaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2016-02-21 08:26:57 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2016-02-21 08:26:57 +0000
commitadcc51666865020347d364f7b3cad8a622124f7a (patch)
tree518a8c37a8f76a7fd1a9f074642d14e0c62cf9c8 /demos
parent951efe320c6a035b67c99deae380b351b2e0b9c0 (diff)
downloadChibiOS-adcc51666865020347d364f7b3cad8a622124f7a.tar.gz
ChibiOS-adcc51666865020347d364f7b3cad8a622124f7a.tar.bz2
ChibiOS-adcc51666865020347d364f7b3cad8a622124f7a.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8918 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos')
-rw-r--r--demos/KINETIS/RT-FREEDOM-K20D50M-EXT/chconf.h42
-rw-r--r--demos/KINETIS/RT-FREEDOM-KL25Z-EXT/chconf.h42
-rw-r--r--demos/KINETIS/RT-MCHCK-K20-GPT/chconf.h42
-rw-r--r--demos/SPC5/NIL-SPC560D-EVB/Makefile2
-rw-r--r--demos/SPC5/RT-SPC560B-EVB/Makefile9
-rw-r--r--demos/SPC5/RT-SPC560B-EVB/main.c68
-rw-r--r--demos/SPC5/RT-SPC560D-EVB/Makefile9
-rw-r--r--demos/SPC5/RT-SPC560D-EVB/main.c68
-rw-r--r--demos/SPC5/RT-SPC560P-EVB/Makefile9
-rw-r--r--demos/SPC5/RT-SPC560P-EVB/main.c68
-rw-r--r--demos/SPC5/RT-SPC563M-EVB/Makefile9
-rw-r--r--demos/SPC5/RT-SPC563M-EVB/main.c68
-rw-r--r--demos/SPC5/RT-SPC564A-EVB/Makefile9
-rw-r--r--demos/SPC5/RT-SPC564A-EVB/main.c68
-rw-r--r--demos/SPC5/RT-SPC56EC-EVB/Makefile9
-rw-r--r--demos/SPC5/RT-SPC56EC-EVB/main.c68
-rw-r--r--demos/SPC5/RT-SPC56EL-EVB/Makefile9
-rw-r--r--demos/SPC5/RT-SPC56EL-EVB/main.c68
-rw-r--r--demos/STM32/CMSIS-STM32F407-DISCOVERY/Makefile2
-rw-r--r--demos/STM32/RT-STM32F103-MAPLEMINI/Makefile9
-rw-r--r--demos/STM32/RT-STM32F103-MAPLEMINI/main.c70
-rw-r--r--demos/STM32/RT-STM32F103-STM3210E_EVAL-FATFS-USB/Makefile11
-rw-r--r--demos/STM32/RT-STM32F103-STM3210E_EVAL-FATFS-USB/main.c89
-rw-r--r--demos/STM32/RT-STM32F103_INEMO_DISCOVERY/Makefile9
-rw-r--r--demos/STM32/RT-STM32F103_INEMO_DISCOVERY/main.c70
-rw-r--r--demos/STM32/RT-STM32F407-DISCOVERY-MEMS/Makefile11
-rw-r--r--demos/STM32/RT-STM32F407-DISCOVERY-MEMS/main.c80
-rw-r--r--demos/STM32/RT-STM32F429-DISCOVERY/Makefile9
-rw-r--r--demos/STM32/RT-STM32F429-DISCOVERY/main.c80
-rw-r--r--demos/STM32/RT-STM32L053R8-NUCLEO/chconf.h2
30 files changed, 268 insertions, 841 deletions
diff --git a/demos/KINETIS/RT-FREEDOM-K20D50M-EXT/chconf.h b/demos/KINETIS/RT-FREEDOM-K20D50M-EXT/chconf.h
index b7a340d6f..ea4adf5f5 100644
--- a/demos/KINETIS/RT-FREEDOM-K20D50M-EXT/chconf.h
+++ b/demos/KINETIS/RT-FREEDOM-K20D50M-EXT/chconf.h
@@ -28,6 +28,8 @@
#ifndef _CHCONF_H_
#define _CHCONF_H_
+#define _CHIBIOS_RT_CONF_
+
/*===========================================================================*/
/**
* @name System timers settings
@@ -360,9 +362,16 @@
* @details If enabled then the context switch circular trace buffer is
* activated.
*
- * @note The default is @p FALSE.
+ * @note The default is @p CH_DBG_TRACE_MASK_NONE.
+ */
+#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_NONE
+
+/**
+ * @brief Trace buffer entries.
+ * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
+ * different from @p CH_DBG_TRACE_MASK_NONE.
*/
-#define CH_DBG_ENABLE_TRACE FALSE
+#define CH_DBG_TRACE_BUFFER_SIZE 128
/**
* @brief Debug option, stack checks.
@@ -427,10 +436,6 @@
/**
* @brief Threads finalization hook.
* @details User finalization code added to the @p chThdExit() API.
- *
- * @note It is inserted into lock zone.
- * @note It is also invoked when the threads simply return in order to
- * terminate.
*/
#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
/* Add threads finalization code here.*/ \
@@ -445,12 +450,27 @@
}
/**
+ * @brief ISR enter hook.
+ */
+#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
+ /* IRQ prologue code here.*/ \
+}
+
+/**
+ * @brief ISR exit hook.
+ */
+#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
+ /* IRQ epilogue code here.*/ \
+}
+
+/**
* @brief Idle thread enter hook.
* @note This hook is invoked within a critical zone, no OS functions
* should be invoked from here.
* @note This macro can be used to activate a power saving mode.
*/
#define CH_CFG_IDLE_ENTER_HOOK() { \
+ /* Idle-enter code here.*/ \
}
/**
@@ -460,6 +480,7 @@
* @note This macro can be used to deactivate a power saving mode.
*/
#define CH_CFG_IDLE_LEAVE_HOOK() { \
+ /* Idle-leave code here.*/ \
}
/**
@@ -488,6 +509,15 @@
/* System halt code here.*/ \
}
+/**
+ * @brief Trace hook.
+ * @details This hook is invoked each time a new record is written in the
+ * trace buffer.
+ */
+#define CH_CFG_TRACE_HOOK(tep) { \
+ /* Trace code here.*/ \
+}
+
/** @} */
/*===========================================================================*/
diff --git a/demos/KINETIS/RT-FREEDOM-KL25Z-EXT/chconf.h b/demos/KINETIS/RT-FREEDOM-KL25Z-EXT/chconf.h
index b7a340d6f..ea4adf5f5 100644
--- a/demos/KINETIS/RT-FREEDOM-KL25Z-EXT/chconf.h
+++ b/demos/KINETIS/RT-FREEDOM-KL25Z-EXT/chconf.h
@@ -28,6 +28,8 @@
#ifndef _CHCONF_H_
#define _CHCONF_H_
+#define _CHIBIOS_RT_CONF_
+
/*===========================================================================*/
/**
* @name System timers settings
@@ -360,9 +362,16 @@
* @details If enabled then the context switch circular trace buffer is
* activated.
*
- * @note The default is @p FALSE.
+ * @note The default is @p CH_DBG_TRACE_MASK_NONE.
+ */
+#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_NONE
+
+/**
+ * @brief Trace buffer entries.
+ * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
+ * different from @p CH_DBG_TRACE_MASK_NONE.
*/
-#define CH_DBG_ENABLE_TRACE FALSE
+#define CH_DBG_TRACE_BUFFER_SIZE 128
/**
* @brief Debug option, stack checks.
@@ -427,10 +436,6 @@
/**
* @brief Threads finalization hook.
* @details User finalization code added to the @p chThdExit() API.
- *
- * @note It is inserted into lock zone.
- * @note It is also invoked when the threads simply return in order to
- * terminate.
*/
#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
/* Add threads finalization code here.*/ \
@@ -445,12 +450,27 @@
}
/**
+ * @brief ISR enter hook.
+ */
+#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
+ /* IRQ prologue code here.*/ \
+}
+
+/**
+ * @brief ISR exit hook.
+ */
+#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
+ /* IRQ epilogue code here.*/ \
+}
+
+/**
* @brief Idle thread enter hook.
* @note This hook is invoked within a critical zone, no OS functions
* should be invoked from here.
* @note This macro can be used to activate a power saving mode.
*/
#define CH_CFG_IDLE_ENTER_HOOK() { \
+ /* Idle-enter code here.*/ \
}
/**
@@ -460,6 +480,7 @@
* @note This macro can be used to deactivate a power saving mode.
*/
#define CH_CFG_IDLE_LEAVE_HOOK() { \
+ /* Idle-leave code here.*/ \
}
/**
@@ -488,6 +509,15 @@
/* System halt code here.*/ \
}
+/**
+ * @brief Trace hook.
+ * @details This hook is invoked each time a new record is written in the
+ * trace buffer.
+ */
+#define CH_CFG_TRACE_HOOK(tep) { \
+ /* Trace code here.*/ \
+}
+
/** @} */
/*===========================================================================*/
diff --git a/demos/KINETIS/RT-MCHCK-K20-GPT/chconf.h b/demos/KINETIS/RT-MCHCK-K20-GPT/chconf.h
index b7a340d6f..ea4adf5f5 100644
--- a/demos/KINETIS/RT-MCHCK-K20-GPT/chconf.h
+++ b/demos/KINETIS/RT-MCHCK-K20-GPT/chconf.h
@@ -28,6 +28,8 @@
#ifndef _CHCONF_H_
#define _CHCONF_H_
+#define _CHIBIOS_RT_CONF_
+
/*===========================================================================*/
/**
* @name System timers settings
@@ -360,9 +362,16 @@
* @details If enabled then the context switch circular trace buffer is
* activated.
*
- * @note The default is @p FALSE.
+ * @note The default is @p CH_DBG_TRACE_MASK_NONE.
+ */
+#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_NONE
+
+/**
+ * @brief Trace buffer entries.
+ * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is
+ * different from @p CH_DBG_TRACE_MASK_NONE.
*/
-#define CH_DBG_ENABLE_TRACE FALSE
+#define CH_DBG_TRACE_BUFFER_SIZE 128
/**
* @brief Debug option, stack checks.
@@ -427,10 +436,6 @@
/**
* @brief Threads finalization hook.
* @details User finalization code added to the @p chThdExit() API.
- *
- * @note It is inserted into lock zone.
- * @note It is also invoked when the threads simply return in order to
- * terminate.
*/
#define CH_CFG_THREAD_EXIT_HOOK(tp) { \
/* Add threads finalization code here.*/ \
@@ -445,12 +450,27 @@
}
/**
+ * @brief ISR enter hook.
+ */
+#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
+ /* IRQ prologue code here.*/ \
+}
+
+/**
+ * @brief ISR exit hook.
+ */
+#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
+ /* IRQ epilogue code here.*/ \
+}
+
+/**
* @brief Idle thread enter hook.
* @note This hook is invoked within a critical zone, no OS functions
* should be invoked from here.
* @note This macro can be used to activate a power saving mode.
*/
#define CH_CFG_IDLE_ENTER_HOOK() { \
+ /* Idle-enter code here.*/ \
}
/**
@@ -460,6 +480,7 @@
* @note This macro can be used to deactivate a power saving mode.
*/
#define CH_CFG_IDLE_LEAVE_HOOK() { \
+ /* Idle-leave code here.*/ \
}
/**
@@ -488,6 +509,15 @@
/* System halt code here.*/ \
}
+/**
+ * @brief Trace hook.
+ * @details This hook is invoked each time a new record is written in the
+ * trace buffer.
+ */
+#define CH_CFG_TRACE_HOOK(tep) { \
+ /* Trace code here.*/ \
+}
+
/** @} */
/*===========================================================================*/
diff --git a/demos/SPC5/NIL-SPC560D-EVB/Makefile b/demos/SPC5/NIL-SPC560D-EVB/Makefile
index 79707db73..810804d03 100644
--- a/demos/SPC5/NIL-SPC560D-EVB/Makefile
+++ b/demos/SPC5/NIL-SPC560D-EVB/Makefile
@@ -91,7 +91,7 @@ include $(CHIBIOS)/os/hal/ports/SPC5/SPC560Dxx/platform.mk
include $(CHIBIOS)/os/hal/osal/nil/osal.mk
# RTOS files (optional).
include $(CHIBIOS)/os/nil/nil.mk
-include $(CHIBIOS)/os/common/startup/e200/compilers/GCC/mk/port.mk
+include $(CHIBIOS)/os/common/ports/e200/compilers/GCC/mk/port.mk
# Other files (optional).
include $(CHIBIOS)/test/nil/test.mk
diff --git a/demos/SPC5/RT-SPC560B-EVB/Makefile b/demos/SPC5/RT-SPC560B-EVB/Makefile
index 172c5cfea..175063aad 100644
--- a/demos/SPC5/RT-SPC560B-EVB/Makefile
+++ b/demos/SPC5/RT-SPC560B-EVB/Makefile
@@ -94,6 +94,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/startup/e200/compilers/GCC/mk/port.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/SPC560B60.ld
@@ -107,9 +109,8 @@ CSRC = $(STARTUPSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
- $(CHIBIOS)/os/various/shell.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
main.c
# C++ sources here.
@@ -120,7 +121,7 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC)
#
# Project, sources and paths
diff --git a/demos/SPC5/RT-SPC560B-EVB/main.c b/demos/SPC5/RT-SPC560B-EVB/main.c
index 957f0e8c2..5b5d89d44 100644
--- a/demos/SPC5/RT-SPC560B-EVB/main.c
+++ b/demos/SPC5/RT-SPC560B-EVB/main.c
@@ -21,63 +21,8 @@
#include "chprintf.h"
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(1024)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state time\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.sp,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{NULL, NULL}
};
@@ -187,15 +132,14 @@ int main(void) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Normal main() thread activity.
+ * Normal main() thread activity, spawning shells.
*/
while (true) {
- if (!shelltp)
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- else if (chThdTerminatedX(shelltp)) {
- chThdRelease(shelltp); /* Recovers memory of the previous shell. */
- shelltp = NULL; /* Triggers spawning of a new shell. */
- }
+ thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
+ chThdWait(shelltp); /* Waiting termination. */
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
chThdSleepMilliseconds(1000);
}
return 0;
diff --git a/demos/SPC5/RT-SPC560D-EVB/Makefile b/demos/SPC5/RT-SPC560D-EVB/Makefile
index efc09d1b8..01d02d200 100644
--- a/demos/SPC5/RT-SPC560D-EVB/Makefile
+++ b/demos/SPC5/RT-SPC560D-EVB/Makefile
@@ -94,6 +94,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/startup/e200/compilers/GCC/mk/port.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/SPC560D40.ld
@@ -107,9 +109,8 @@ CSRC = $(STARTUPSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
- $(CHIBIOS)/os/various/shell.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
main.c
# C++ sources here.
@@ -120,7 +121,7 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC)
#
# Project, sources and paths
diff --git a/demos/SPC5/RT-SPC560D-EVB/main.c b/demos/SPC5/RT-SPC560D-EVB/main.c
index a83128f2c..5b5d89d44 100644
--- a/demos/SPC5/RT-SPC560D-EVB/main.c
+++ b/demos/SPC5/RT-SPC560D-EVB/main.c
@@ -21,63 +21,8 @@
#include "chprintf.h"
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(1024)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size, largest;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size, &largest);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
- chprintf(chp, "heap free largest: %u bytes\r\n", largest);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state time\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->ctx.sp,
- (uint32_t)tp->prio, states[tp->state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{NULL, NULL}
};
@@ -187,15 +132,14 @@ int main(void) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Normal main() thread activity.
+ * Normal main() thread activity, spawning shells.
*/
while (true) {
- if (!shelltp)
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- else if (chThdTerminatedX(shelltp)) {
- chThdRelease(shelltp); /* Recovers memory of the previous shell. */
- shelltp = NULL; /* Triggers spawning of a new shell. */
- }
+ thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
+ chThdWait(shelltp); /* Waiting termination. */
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
chThdSleepMilliseconds(1000);
}
return 0;
diff --git a/demos/SPC5/RT-SPC560P-EVB/Makefile b/demos/SPC5/RT-SPC560P-EVB/Makefile
index 324411796..22cad7e1f 100644
--- a/demos/SPC5/RT-SPC560P-EVB/Makefile
+++ b/demos/SPC5/RT-SPC560P-EVB/Makefile
@@ -94,6 +94,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/e200/compilers/GCC/mk/port.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/SPC560P50.ld
@@ -107,9 +109,8 @@ CSRC = $(STARTUPSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
- $(CHIBIOS)/os/various/shell.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
main.c
# C++ sources here.
@@ -120,7 +121,7 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC)
#
# Project, sources and paths
diff --git a/demos/SPC5/RT-SPC560P-EVB/main.c b/demos/SPC5/RT-SPC560P-EVB/main.c
index 1806961b2..07087821d 100644
--- a/demos/SPC5/RT-SPC560P-EVB/main.c
+++ b/demos/SPC5/RT-SPC560P-EVB/main.c
@@ -21,63 +21,8 @@
#include "chprintf.h"
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(1024)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state time\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.sp,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{NULL, NULL}
};
@@ -187,15 +132,14 @@ int main(void) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Normal main() thread activity.
+ * Normal main() thread activity, spawning shells.
*/
while (true) {
- if (!shelltp)
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- else if (chThdTerminatedX(shelltp)) {
- chThdRelease(shelltp); /* Recovers memory of the previous shell. */
- shelltp = NULL; /* Triggers spawning of a new shell. */
- }
+ thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
+ chThdWait(shelltp); /* Waiting termination. */
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
chThdSleepMilliseconds(1000);
}
return 0;
diff --git a/demos/SPC5/RT-SPC563M-EVB/Makefile b/demos/SPC5/RT-SPC563M-EVB/Makefile
index d9caf5cf8..336f346f8 100644
--- a/demos/SPC5/RT-SPC563M-EVB/Makefile
+++ b/demos/SPC5/RT-SPC563M-EVB/Makefile
@@ -94,6 +94,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/e200/compilers/GCC/mk/port.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/SPC563M64.ld
@@ -107,9 +109,8 @@ CSRC = $(STARTUPSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
- $(CHIBIOS)/os/various/shell.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
main.c
# C++ sources here.
@@ -120,7 +121,7 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC)
#
# Project, sources and paths
diff --git a/demos/SPC5/RT-SPC563M-EVB/main.c b/demos/SPC5/RT-SPC563M-EVB/main.c
index ab881fdc4..866212741 100644
--- a/demos/SPC5/RT-SPC563M-EVB/main.c
+++ b/demos/SPC5/RT-SPC563M-EVB/main.c
@@ -21,63 +21,8 @@
#include "chprintf.h"
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(1024)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state time\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.sp,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{NULL, NULL}
};
@@ -170,15 +115,14 @@ int main(void) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Normal main() thread activity.
+ * Normal main() thread activity, spawning shells.
*/
while (true) {
- if (!shelltp)
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- else if (chThdTerminatedX(shelltp)) {
- chThdRelease(shelltp); /* Recovers memory of the previous shell. */
- shelltp = NULL; /* Triggers spawning of a new shell. */
- }
+ thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
+ chThdWait(shelltp); /* Waiting termination. */
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
chThdSleepMilliseconds(1000);
}
return 0;
diff --git a/demos/SPC5/RT-SPC564A-EVB/Makefile b/demos/SPC5/RT-SPC564A-EVB/Makefile
index 43349cde5..621fb7f84 100644
--- a/demos/SPC5/RT-SPC564A-EVB/Makefile
+++ b/demos/SPC5/RT-SPC564A-EVB/Makefile
@@ -94,6 +94,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/e200/compilers/GCC/mk/port.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/SPC564A80.ld
@@ -107,9 +109,8 @@ CSRC = $(STARTUPSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
- $(CHIBIOS)/os/various/shell.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
main.c
# C++ sources here.
@@ -120,7 +121,7 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC)
#
# Project, sources and paths
diff --git a/demos/SPC5/RT-SPC564A-EVB/main.c b/demos/SPC5/RT-SPC564A-EVB/main.c
index ab881fdc4..866212741 100644
--- a/demos/SPC5/RT-SPC564A-EVB/main.c
+++ b/demos/SPC5/RT-SPC564A-EVB/main.c
@@ -21,63 +21,8 @@
#include "chprintf.h"
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(1024)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state time\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.sp,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{NULL, NULL}
};
@@ -170,15 +115,14 @@ int main(void) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Normal main() thread activity.
+ * Normal main() thread activity, spawning shells.
*/
while (true) {
- if (!shelltp)
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- else if (chThdTerminatedX(shelltp)) {
- chThdRelease(shelltp); /* Recovers memory of the previous shell. */
- shelltp = NULL; /* Triggers spawning of a new shell. */
- }
+ thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
+ chThdWait(shelltp); /* Waiting termination. */
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
chThdSleepMilliseconds(1000);
}
return 0;
diff --git a/demos/SPC5/RT-SPC56EC-EVB/Makefile b/demos/SPC5/RT-SPC56EC-EVB/Makefile
index edb9063a2..89e2c1509 100644
--- a/demos/SPC5/RT-SPC56EC-EVB/Makefile
+++ b/demos/SPC5/RT-SPC56EC-EVB/Makefile
@@ -94,6 +94,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/e200/compilers/GCC/mk/port.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/SPC56EC74.ld
@@ -107,9 +109,8 @@ CSRC = $(STARTUPSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
- $(CHIBIOS)/os/various/shell.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
main.c
# C++ sources here.
@@ -120,7 +121,7 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC)
#
# Project, sources and paths
diff --git a/demos/SPC5/RT-SPC56EC-EVB/main.c b/demos/SPC5/RT-SPC56EC-EVB/main.c
index 957f0e8c2..5b5d89d44 100644
--- a/demos/SPC5/RT-SPC56EC-EVB/main.c
+++ b/demos/SPC5/RT-SPC56EC-EVB/main.c
@@ -21,63 +21,8 @@
#include "chprintf.h"
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(1024)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state time\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.sp,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{NULL, NULL}
};
@@ -187,15 +132,14 @@ int main(void) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Normal main() thread activity.
+ * Normal main() thread activity, spawning shells.
*/
while (true) {
- if (!shelltp)
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- else if (chThdTerminatedX(shelltp)) {
- chThdRelease(shelltp); /* Recovers memory of the previous shell. */
- shelltp = NULL; /* Triggers spawning of a new shell. */
- }
+ thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
+ chThdWait(shelltp); /* Waiting termination. */
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
chThdSleepMilliseconds(1000);
}
return 0;
diff --git a/demos/SPC5/RT-SPC56EL-EVB/Makefile b/demos/SPC5/RT-SPC56EL-EVB/Makefile
index 67f82a43f..009fd1219 100644
--- a/demos/SPC5/RT-SPC56EL-EVB/Makefile
+++ b/demos/SPC5/RT-SPC56EL-EVB/Makefile
@@ -94,6 +94,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/e200/compilers/GCC/mk/port.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/SPC56EL60_LSM.ld
@@ -107,9 +109,8 @@ CSRC = $(STARTUPSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
- $(CHIBIOS)/os/various/shell.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
main.c
# C++ sources here.
@@ -120,7 +121,7 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC)
#
# Project, sources and paths
diff --git a/demos/SPC5/RT-SPC56EL-EVB/main.c b/demos/SPC5/RT-SPC56EL-EVB/main.c
index 1806961b2..07087821d 100644
--- a/demos/SPC5/RT-SPC56EL-EVB/main.c
+++ b/demos/SPC5/RT-SPC56EL-EVB/main.c
@@ -21,63 +21,8 @@
#include "chprintf.h"
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(1024)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state time\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.sp,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{NULL, NULL}
};
@@ -187,15 +132,14 @@ int main(void) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Normal main() thread activity.
+ * Normal main() thread activity, spawning shells.
*/
while (true) {
- if (!shelltp)
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- else if (chThdTerminatedX(shelltp)) {
- chThdRelease(shelltp); /* Recovers memory of the previous shell. */
- shelltp = NULL; /* Triggers spawning of a new shell. */
- }
+ thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
+ chThdWait(shelltp); /* Waiting termination. */
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
chThdSleepMilliseconds(1000);
}
return 0;
diff --git a/demos/STM32/CMSIS-STM32F407-DISCOVERY/Makefile b/demos/STM32/CMSIS-STM32F407-DISCOVERY/Makefile
index e81701cc8..ee50b2c53 100644
--- a/demos/STM32/CMSIS-STM32F407-DISCOVERY/Makefile
+++ b/demos/STM32/CMSIS-STM32F407-DISCOVERY/Makefile
@@ -99,7 +99,7 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
-include $(CHIBIOS)/os/common/startup/ARMCMx/cmsis_os/cmsis_os.mk
+include $(CHIBIOS)/os/common/ports/ARMCMx/cmsis_os/cmsis_os.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/STM32F407xG.ld
diff --git a/demos/STM32/RT-STM32F103-MAPLEMINI/Makefile b/demos/STM32/RT-STM32F103-MAPLEMINI/Makefile
index 60d87468d..1e1090d40 100644
--- a/demos/STM32/RT-STM32F103-MAPLEMINI/Makefile
+++ b/demos/STM32/RT-STM32F103-MAPLEMINI/Makefile
@@ -102,6 +102,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# Define linker script file here
ifeq ($(USE_MAPLEMINI_BOOTLOADER),1)
@@ -120,9 +122,8 @@ CSRC = $(STARTUPSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
- $(CHIBIOS)/os/various/shell.c \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
usbcfg.c main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -154,7 +155,7 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC)
#
# Project, sources and paths
diff --git a/demos/STM32/RT-STM32F103-MAPLEMINI/main.c b/demos/STM32/RT-STM32F103-MAPLEMINI/main.c
index 5ce15913b..6b85c77a0 100644
--- a/demos/STM32/RT-STM32F103-MAPLEMINI/main.c
+++ b/demos/STM32/RT-STM32F103-MAPLEMINI/main.c
@@ -31,58 +31,6 @@
/*===========================================================================*/
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.r13,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
/* Can be measured using dd if=/dev/xxxx of=/dev/null bs=512 count=10000.*/
static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {
@@ -125,9 +73,6 @@ static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {
}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{"write", cmd_write},
{NULL, NULL}
};
@@ -162,7 +107,6 @@ static __attribute__((noreturn)) THD_FUNCTION(Thread1, arg) {
* Application entry point.
*/
int __attribute__((noreturn)) main(void) {
- thread_t *shelltp = NULL;
/*
* System initializations.
@@ -201,15 +145,15 @@ int __attribute__((noreturn)) main(void) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Normal main() thread activity, in this demo it does nothing except
- * sleeping in a loop and check the button state.
+ * Normal main() thread activity, spawning shells.
*/
while (true) {
- if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE))
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- else if (chThdTerminatedX(shelltp)) {
- chThdRelease(shelltp); /* Recovers memory of the previous shell. */
- shelltp = NULL; /* Triggers spawning of a new shell. */
+ if (SDU1.config->usbp->state == USB_ACTIVE) {
+ thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
+ chThdWait(shelltp); /* Waiting termination. */
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
}
chThdSleepMilliseconds(1000);
}
diff --git a/demos/STM32/RT-STM32F103-STM3210E_EVAL-FATFS-USB/Makefile b/demos/STM32/RT-STM32F103-STM3210E_EVAL-FATFS-USB/Makefile
index 64b7dbad6..dc4293009 100644
--- a/demos/STM32/RT-STM32F103-STM3210E_EVAL-FATFS-USB/Makefile
+++ b/demos/STM32/RT-STM32F103-STM3210E_EVAL-FATFS-USB/Makefile
@@ -99,6 +99,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
include $(CHIBIOS)/os/various/lwip_bindings/lwip.mk
include $(CHIBIOS)/os/various/fatfs_bindings/fatfs.mk
@@ -116,10 +118,8 @@ CSRC = $(STARTUPSRC) \
$(BOARDSRC) \
$(TESTSRC) \
$(FATFSSRC) \
- $(CHIBIOS)/os/various/evtimer.c \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
- $(CHIBIOS)/os/various/shell.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
usbcfg.c main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -151,8 +151,7 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(FATFSINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC) $(FATFSINC)
#
# Project, sources and paths
diff --git a/demos/STM32/RT-STM32F103-STM3210E_EVAL-FATFS-USB/main.c b/demos/STM32/RT-STM32F103-STM3210E_EVAL-FATFS-USB/main.c
index 4d60b3b33..54fe64ee6 100644
--- a/demos/STM32/RT-STM32F103-STM3210E_EVAL-FATFS-USB/main.c
+++ b/demos/STM32/RT-STM32F103-STM3210E_EVAL-FATFS-USB/main.c
@@ -154,58 +154,6 @@ static FRESULT scan_files(BaseSequentialStream *chp, char *path) {
/*===========================================================================*/
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state time\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.r13,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
static void cmd_tree(BaseSequentialStream *chp, int argc, char *argv[]) {
FRESULT err;
@@ -235,9 +183,6 @@ static void cmd_tree(BaseSequentialStream *chp, int argc, char *argv[]) {
}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{"tree", cmd_tree},
{NULL, NULL}
};
@@ -251,6 +196,8 @@ static const ShellConfig shell_cfg1 = {
/* Main and generic code. */
/*===========================================================================*/
+static thread_t *shelltp = NULL;
+
/*
* Card insertion event.
*/
@@ -283,6 +230,18 @@ static void RemoveHandler(eventid_t id) {
}
/*
+ * Shell exit event.
+ */
+static void ShellHandler(eventid_t id) {
+
+ (void)id;
+ if (chThdTerminatedX(shelltp)) {
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
+ shelltp = NULL;
+ }
+}
+
+/*
* Green LED blinker thread, times are in milliseconds.
*/
static THD_WORKING_AREA(waThread1, 128);
@@ -300,12 +259,12 @@ static THD_FUNCTION(Thread1, arg) {
* Application entry point.
*/
int main(void) {
- static thread_t *shelltp = NULL;
static const evhandler_t evhndl[] = {
InsertHandler,
- RemoveHandler
+ RemoveHandler,
+ ShellHandler
};
- event_listener_t el0, el1;
+ event_listener_t el0, el1, el2;
/*
* System initializations.
@@ -349,17 +308,17 @@ int main(void) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Normal main() thread activity, in this demo it does nothing except
- * sleeping in a loop and listen for events.
+ * Normal main() thread activity, handling SD card events and shell
+ * start/exit.
*/
chEvtRegister(&inserted_event, &el0, 0);
chEvtRegister(&removed_event, &el1, 1);
+ chEvtRegister(&shell_terminated, &el2, 2);
while (true) {
- if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE))
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- else if (chThdTerminatedX(shelltp)) {
- chThdRelease(shelltp); /* Recovers memory of the previous shell. */
- shelltp = NULL; /* Triggers spawning of a new shell. */
+ if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE)) {
+ shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
}
chEvtDispatch(evhndl, chEvtWaitOneTimeout(ALL_EVENTS, MS2ST(500)));
}
diff --git a/demos/STM32/RT-STM32F103_INEMO_DISCOVERY/Makefile b/demos/STM32/RT-STM32F103_INEMO_DISCOVERY/Makefile
index 82a14c13e..cb84f6c7c 100644
--- a/demos/STM32/RT-STM32F103_INEMO_DISCOVERY/Makefile
+++ b/demos/STM32/RT-STM32F103_INEMO_DISCOVERY/Makefile
@@ -99,6 +99,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/STM32F103xE.ld
@@ -113,9 +115,8 @@ CSRC = $(STARTUPSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
- $(CHIBIOS)/os/various/shell.c \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
usbcfg.c main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -147,7 +148,7 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC)
#
# Project, sources and paths
diff --git a/demos/STM32/RT-STM32F103_INEMO_DISCOVERY/main.c b/demos/STM32/RT-STM32F103_INEMO_DISCOVERY/main.c
index 2515f18cb..2588fb35a 100644
--- a/demos/STM32/RT-STM32F103_INEMO_DISCOVERY/main.c
+++ b/demos/STM32/RT-STM32F103_INEMO_DISCOVERY/main.c
@@ -31,58 +31,6 @@
/*===========================================================================*/
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.r13,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
/* Can be measured using dd if=/dev/xxxx of=/dev/null bs=512 count=10000.*/
static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {
@@ -125,9 +73,6 @@ static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {
}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{"write", cmd_write},
{NULL, NULL}
};
@@ -162,7 +107,6 @@ static THD_FUNCTION(Thread1, arg) {
* Application entry point.
*/
int main(void) {
- thread_t *shelltp = NULL;
/*
* System initializations.
@@ -201,15 +145,15 @@ int main(void) {
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
/*
- * Normal main() thread activity, in this demo it does nothing except
- * sleeping in a loop and check the button state.
+ * Normal main() thread activity, spawning shells.
*/
while (true) {
- if (!shelltp && (SDU1.config->usbp->state == USB_ACTIVE))
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- else if (chThdTerminatedX(shelltp)) {
- chThdRelease(shelltp); /* Recovers memory of the previous shell. */
- shelltp = NULL; /* Triggers spawning of a new shell. */
+ if (SDU1.config->usbp->state == USB_ACTIVE) {
+ thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
+ chThdWait(shelltp); /* Waiting termination. */
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
}
chThdSleepMilliseconds(1000);
}
diff --git a/demos/STM32/RT-STM32F407-DISCOVERY-MEMS/Makefile b/demos/STM32/RT-STM32F407-DISCOVERY-MEMS/Makefile
index 477373a6c..7f986b30b 100644
--- a/demos/STM32/RT-STM32F407-DISCOVERY-MEMS/Makefile
+++ b/demos/STM32/RT-STM32F407-DISCOVERY-MEMS/Makefile
@@ -99,6 +99,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/STM32F407xG.ld
@@ -113,10 +115,9 @@ CSRC = $(STARTUPSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
$(CHIBIOS)/os/various/devices_lib/accel/lis302dl.c \
- $(CHIBIOS)/os/various/shell.c \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
usbcfg.c main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -148,8 +149,8 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/various/devices_lib/accel \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC) \
+ $(CHIBIOS)/os/various/devices_lib/accel
#
# Project, sources and paths
diff --git a/demos/STM32/RT-STM32F407-DISCOVERY-MEMS/main.c b/demos/STM32/RT-STM32F407-DISCOVERY-MEMS/main.c
index 1c02f91f7..820163f4f 100644
--- a/demos/STM32/RT-STM32F407-DISCOVERY-MEMS/main.c
+++ b/demos/STM32/RT-STM32F407-DISCOVERY-MEMS/main.c
@@ -29,63 +29,8 @@
/*===========================================================================*/
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.r13,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{NULL, NULL}
};
@@ -220,7 +165,6 @@ static THD_FUNCTION(Thread1, arg) {
* Application entry point.
*/
int main(void) {
- thread_t *shelltp = NULL;
/*
* System initializations.
@@ -300,24 +244,16 @@ int main(void) {
NORMALPRIO + 10, Thread1, NULL);
/*
- * Normal main() thread activity, in this demo it just performs
- * a shell respawn upon its termination.
+ * Normal main() thread activity, spawning shells.
*/
while (true) {
- if (!shelltp) {
- if (SDU1.config->usbp->state == USB_ACTIVE) {
- /* Spawns a new shell.*/
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- }
- }
- else {
- /* If the previous shell exited.*/
- if (chThdTerminatedX(shelltp)) {
- /* Recovers memory of the previous shell.*/
- chThdRelease(shelltp);
- shelltp = NULL;
- }
+ if (SDU1.config->usbp->state == USB_ACTIVE) {
+ thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
+ chThdWait(shelltp); /* Waiting termination. */
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
}
- chThdSleepMilliseconds(500);
+ chThdSleepMilliseconds(1000);
}
}
diff --git a/demos/STM32/RT-STM32F429-DISCOVERY/Makefile b/demos/STM32/RT-STM32F429-DISCOVERY/Makefile
index 5d4e6f54b..f0b718b91 100644
--- a/demos/STM32/RT-STM32F429-DISCOVERY/Makefile
+++ b/demos/STM32/RT-STM32F429-DISCOVERY/Makefile
@@ -99,6 +99,8 @@ include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk
+include $(CHIBIOS)/os/hal/lib/streams/streams.mk
+include $(CHIBIOS)/os/various/shell/shell.mk
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/STM32F429xI.ld
@@ -113,9 +115,8 @@ CSRC = $(STARTUPSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(TESTSRC) \
- $(CHIBIOS)/os/various/shell.c \
- $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
- $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
+ $(STREAMSSRC) \
+ $(SHELLSRC) \
usbcfg.c main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
@@ -147,7 +148,7 @@ ASMSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)
INCDIR = $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
- $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various
+ $(STREAMSINC) $(SHELLINC)
#
# Project, sources and paths
diff --git a/demos/STM32/RT-STM32F429-DISCOVERY/main.c b/demos/STM32/RT-STM32F429-DISCOVERY/main.c
index f423b233e..0f42d959f 100644
--- a/demos/STM32/RT-STM32F429-DISCOVERY/main.c
+++ b/demos/STM32/RT-STM32F429-DISCOVERY/main.c
@@ -60,63 +60,8 @@ static THD_FUNCTION(Thread2, arg) {
/*===========================================================================*/
#define SHELL_WA_SIZE THD_WORKING_AREA_SIZE(2048)
-#define TEST_WA_SIZE THD_WORKING_AREA_SIZE(256)
-
-static void cmd_mem(BaseSequentialStream *chp, int argc, char *argv[]) {
- size_t n, size;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: mem\r\n");
- return;
- }
- n = chHeapStatus(NULL, &size);
- chprintf(chp, "core free memory : %u bytes\r\n", chCoreGetStatusX());
- chprintf(chp, "heap fragments : %u\r\n", n);
- chprintf(chp, "heap free total : %u bytes\r\n", size);
-}
-
-static void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) {
- static const char *states[] = {CH_STATE_NAMES};
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: threads\r\n");
- return;
- }
- chprintf(chp, " addr stack prio refs state time\r\n");
- tp = chRegFirstThread();
- do {
- chprintf(chp, "%08lx %08lx %4lu %4lu %9s\r\n",
- (uint32_t)tp, (uint32_t)tp->p_ctx.r13,
- (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
- states[tp->p_state]);
- tp = chRegNextThread(tp);
- } while (tp != NULL);
-}
-
-static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
- thread_t *tp;
-
- (void)argv;
- if (argc > 0) {
- chprintf(chp, "Usage: test\r\n");
- return;
- }
- tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriorityX(),
- TestThread, chp);
- if (tp == NULL) {
- chprintf(chp, "out of memory\r\n");
- return;
- }
- chThdWait(tp);
-}
static const ShellCommand commands[] = {
- {"mem", cmd_mem},
- {"threads", cmd_threads},
- {"test", cmd_test},
{NULL, NULL}
};
@@ -133,7 +78,6 @@ static const ShellConfig shell_cfg1 = {
* Application entry point.
*/
int main(void) {
- thread_t *shelltp = NULL;
/*
* System initializations.
@@ -175,24 +119,16 @@ int main(void) {
NORMALPRIO + 10, Thread2, NULL);
/*
- * Normal main() thread activity, in this demo it just performs
- * a shell respawn upon its termination.
+ * Normal main() thread activity, spawning shells.
*/
while (true) {
- if (!shelltp) {
- if (SDU1.config->usbp->state == USB_ACTIVE) {
- /* Spawns a new shell.*/
- shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
- }
- }
- else {
- /* If the previous shell exited.*/
- if (chThdTerminatedX(shelltp)) {
- /* Recovers memory of the previous shell.*/
- chThdRelease(shelltp);
- shelltp = NULL;
- }
+ if (SDU1.config->usbp->state == USB_ACTIVE) {
+ thread_t *shelltp = chThdCreateFromHeap(NULL, SHELL_WA_SIZE,
+ NORMALPRIO + 1, shellThread,
+ (void *)&shell_cfg1);
+ chThdWait(shelltp); /* Waiting termination. */
+ chThdFreeToHeap(shelltp); /* Returning memory to heap. */
}
- chThdSleepMilliseconds(500);
+ chThdSleepMilliseconds(1000);
}
}
diff --git a/demos/STM32/RT-STM32L053R8-NUCLEO/chconf.h b/demos/STM32/RT-STM32L053R8-NUCLEO/chconf.h
index 1684bb4b5..b88665f4c 100644
--- a/demos/STM32/RT-STM32L053R8-NUCLEO/chconf.h
+++ b/demos/STM32/RT-STM32L053R8-NUCLEO/chconf.h
@@ -140,7 +140,7 @@
*
* @note The default is @p TRUE.
*/
-#define CH_CFG_USE_TM TRUE
+#define CH_CFG_USE_TM FALSE
/**
* @brief Threads registry APIs.