diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-02-21 08:26:57 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-02-21 08:26:57 +0000 |
commit | adcc51666865020347d364f7b3cad8a622124f7a (patch) | |
tree | 518a8c37a8f76a7fd1a9f074642d14e0c62cf9c8 /demos/SPC5/RT-SPC560P-EVB | |
parent | 951efe320c6a035b67c99deae380b351b2e0b9c0 (diff) | |
download | ChibiOS-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/SPC5/RT-SPC560P-EVB')
-rw-r--r-- | demos/SPC5/RT-SPC560P-EVB/Makefile | 9 | ||||
-rw-r--r-- | demos/SPC5/RT-SPC560P-EVB/main.c | 68 |
2 files changed, 11 insertions, 66 deletions
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;
|