diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-02-20 18:53:30 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-02-20 18:53:30 +0000 |
commit | 41585364a77e8d8491c958525d1f0446fe2772e9 (patch) | |
tree | b9cdb86310678f066c78732a527885a611eb5bd9 /testhal/STM32/STM32F1xx | |
parent | 54b63fd3bb931702581eca0ffb1d470923046c81 (diff) | |
download | ChibiOS-41585364a77e8d8491c958525d1f0446fe2772e9.tar.gz ChibiOS-41585364a77e8d8491c958525d1f0446fe2772e9.tar.bz2 ChibiOS-41585364a77e8d8491c958525d1f0446fe2772e9.zip |
Updated CDC demos under testhal with new shell.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8916 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32/STM32F1xx')
-rw-r--r-- | testhal/STM32/STM32F1xx/USB_CDC/Makefile | 9 | ||||
-rw-r--r-- | testhal/STM32/STM32F1xx/USB_CDC/main.c | 70 |
2 files changed, 12 insertions, 67 deletions
diff --git a/testhal/STM32/STM32F1xx/USB_CDC/Makefile b/testhal/STM32/STM32F1xx/USB_CDC/Makefile index f8d1947b7..2815c4568 100644 --- a/testhal/STM32/STM32F1xx/USB_CDC/Makefile +++ b/testhal/STM32/STM32F1xx/USB_CDC/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)/STM32F103xB.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/testhal/STM32/STM32F1xx/USB_CDC/main.c b/testhal/STM32/STM32F1xx/USB_CDC/main.c index b5f4231ef..17c49f749 100644 --- a/testhal/STM32/STM32F1xx/USB_CDC/main.c +++ b/testhal/STM32/STM32F1xx/USB_CDC/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 %lu\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}
};
@@ -163,7 +108,6 @@ static THD_FUNCTION(Thread1, arg) { * Application entry point.
*/
int main(void) {
- thread_t *shelltp = NULL;
/*
* System initializations.
@@ -202,15 +146,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);
}
|