From e10edf16834d7dbe0c4ce7ea88c634e31b7d3113 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 27 Jun 2011 19:57:11 +0000 Subject: Dedicated printf implementation. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3092 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARMCM3-STM32F103-FATFS/main.c | 38 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'demos/ARMCM3-STM32F103-FATFS/main.c') diff --git a/demos/ARMCM3-STM32F103-FATFS/main.c b/demos/ARMCM3-STM32F103-FATFS/main.c index a5bfb13a8..98eb19962 100644 --- a/demos/ARMCM3-STM32F103-FATFS/main.c +++ b/demos/ARMCM3-STM32F103-FATFS/main.c @@ -18,7 +18,6 @@ along with this program. If not, see . */ -#include #include #include "ch.h" @@ -26,6 +25,7 @@ #include "test.h" #include "shell.h" #include "evtimer.h" +#include "chprintf.h" #include "ff.h" @@ -62,7 +62,7 @@ static bool_t mmc_is_protected(void) {return !palReadPad(IOPORT3, GPIOC_MMCWP);} /* Generic large buffer.*/ uint8_t fbuff[1024]; -static FRESULT scan_files(char *path) +static FRESULT scan_files(BaseChannel *chp, char *path) { FRESULT res; FILINFO fno; @@ -81,14 +81,15 @@ static FRESULT scan_files(char *path) continue; fn = fno.fname; if (fno.fattrib & AM_DIR) { - siprintf(&path[i], "/%s", fn); - res = scan_files(path); + path[i++] = '/'; + strcpy(&path[i], fn); + res = scan_files(chp, path); if (res != FR_OK) break; path[i] = 0; } else { - iprintf("%s/%s\r\n", path, fn); + chprintf(chp, "%s/%s\r\n", path, fn); } } } @@ -104,7 +105,6 @@ static FRESULT scan_files(char *path) static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { size_t n, size; - char buf[52]; (void)argv; if (argc > 0) { @@ -112,12 +112,9 @@ static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { return; } n = chHeapStatus(NULL, &size); - siprintf(buf, "core free memory : %u bytes", chCoreStatus()); - shellPrintLine(chp, buf); - siprintf(buf, "heap fragments : %u", n); - shellPrintLine(chp, buf); - siprintf(buf, "heap free total : %u bytes", size); - shellPrintLine(chp, buf); + chprintf(chp, "core free memory : %u bytes\r\n", chCoreStatus()); + chprintf(chp, "heap fragments : %u\r\n", n); + chprintf(chp, "heap free total : %u bytes\r\n", size); } static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { @@ -138,7 +135,6 @@ static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { "FINAL" }; Thread *tp; - char buf[60]; (void)argv; if (argc > 0) { @@ -148,11 +144,10 @@ static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { shellPrintLine(chp, " addr stack prio refs state time"); tp = chRegFirstThread(); do { - siprintf(buf, "%8lx %8lx %4u %4i %9s %u", - (uint32_t)tp, (uint32_t)tp->p_ctx.r13, - (unsigned int)tp->p_prio, tp->p_refs - 1, - states[tp->p_state], (unsigned int)tp->p_time); - shellPrintLine(chp, buf); + chprintf(chp, "%.8lx %.8lx %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], (uint32_t)tp->p_time); tp = chRegNextThread(tp); } while (tp != NULL); } @@ -193,13 +188,12 @@ static void cmd_tree(BaseChannel *chp, int argc, char *argv[]) { shellPrintLine(chp, "FS: f_getfree() failed"); return; } - siprintf((void *)fbuff, - "FS: %lu free clusters, %lu sectors per cluster, %lu bytes free", + chprintf(chp, + "FS: %lu free clusters, %lu sectors per cluster, %lu bytes free\r\n", clusters, (uint32_t)MMC_FS.csize, clusters * (uint32_t)MMC_FS.csize * (uint32_t)MMC_SECTOR_SIZE); - shellPrintLine(chp, (void *)fbuff); fbuff[0] = 0; - scan_files((char *)fbuff); + scan_files(chp, (char *)fbuff); } static const ShellCommand commands[] = { -- cgit v1.2.3 From ddc9ded3f065d8da59a843390814b1c19061c566 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 28 Jun 2011 06:29:04 +0000 Subject: chprintf() implemented, improved the shell. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3093 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARMCM3-STM32F103-FATFS/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'demos/ARMCM3-STM32F103-FATFS/main.c') diff --git a/demos/ARMCM3-STM32F103-FATFS/main.c b/demos/ARMCM3-STM32F103-FATFS/main.c index 98eb19962..e3a5fc6ad 100644 --- a/demos/ARMCM3-STM32F103-FATFS/main.c +++ b/demos/ARMCM3-STM32F103-FATFS/main.c @@ -108,7 +108,7 @@ static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) { (void)argv; if (argc > 0) { - shellPrintLine(chp, "Usage: mem"); + chprintf(chp, "Usage: mem\r\n"); return; } n = chHeapStatus(NULL, &size); @@ -138,10 +138,10 @@ static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { (void)argv; if (argc > 0) { - shellPrintLine(chp, "Usage: threads"); + chprintf(chp, "Usage: threads\r\n"); return; } - shellPrintLine(chp, " addr stack prio refs state time"); + chprintf(chp, " addr stack prio refs state time\r\n"); tp = chRegFirstThread(); do { chprintf(chp, "%.8lx %.8lx %4lu %4lu %9s %lu\r\n", @@ -157,13 +157,13 @@ static void cmd_test(BaseChannel *chp, int argc, char *argv[]) { (void)argv; if (argc > 0) { - shellPrintLine(chp, "Usage: test"); + chprintf(chp, "Usage: test\r\n"); return; } tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriority(), TestThread, chp); if (tp == NULL) { - shellPrintLine(chp, "out of memory"); + chprintf(chp, "out of memory\r\n"); return; } chThdWait(tp); @@ -176,16 +176,16 @@ static void cmd_tree(BaseChannel *chp, int argc, char *argv[]) { (void)argv; if (argc > 0) { - shellPrintLine(chp, "Usage: tree"); + chprintf(chp, "Usage: tree\r\n"); return; } if (!fs_ready) { - shellPrintLine(chp, "File System not mounted"); + chprintf(chp, "File System not mounted\r\n"); return; } err = f_getfree("/", &clusters, &fsp); if (err != FR_OK) { - shellPrintLine(chp, "FS: f_getfree() failed"); + chprintf(chp, "FS: f_getfree() failed\r\n"); return; } chprintf(chp, -- cgit v1.2.3 From 7bdd564b9d903146bbfc02fe38e586fc8e15f282 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 28 Jun 2011 06:54:35 +0000 Subject: Updated demos using the shell. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3094 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARMCM3-STM32F103-FATFS/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'demos/ARMCM3-STM32F103-FATFS/main.c') diff --git a/demos/ARMCM3-STM32F103-FATFS/main.c b/demos/ARMCM3-STM32F103-FATFS/main.c index e3a5fc6ad..a6404bf74 100644 --- a/demos/ARMCM3-STM32F103-FATFS/main.c +++ b/demos/ARMCM3-STM32F103-FATFS/main.c @@ -62,8 +62,7 @@ static bool_t mmc_is_protected(void) {return !palReadPad(IOPORT3, GPIOC_MMCWP);} /* Generic large buffer.*/ uint8_t fbuff[1024]; -static FRESULT scan_files(BaseChannel *chp, char *path) -{ +static FRESULT scan_files(BaseChannel *chp, char *path) { FRESULT res; FILINFO fno; DIR dir; -- cgit v1.2.3 From 83c5424c5f6d3c970a32e6303033ff651bf0287b Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 3 Jul 2011 15:29:13 +0000 Subject: Fixed bug 3351556. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3108 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARMCM3-STM32F103-FATFS/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'demos/ARMCM3-STM32F103-FATFS/main.c') diff --git a/demos/ARMCM3-STM32F103-FATFS/main.c b/demos/ARMCM3-STM32F103-FATFS/main.c index a6404bf74..5efa25f4c 100644 --- a/demos/ARMCM3-STM32F103-FATFS/main.c +++ b/demos/ARMCM3-STM32F103-FATFS/main.c @@ -131,6 +131,7 @@ static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) { "SNDMSGQ", "SNDMSG", "WTMSG", + "WTQUEUE", "FINAL" }; Thread *tp; -- cgit v1.2.3 From 8f03a390471628081bd78b7c5f34a0a6a404ee95 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 10 Jul 2011 06:50:12 +0000 Subject: Added thread names to all demos. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3143 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARMCM3-STM32F103-FATFS/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'demos/ARMCM3-STM32F103-FATFS/main.c') diff --git a/demos/ARMCM3-STM32F103-FATFS/main.c b/demos/ARMCM3-STM32F103-FATFS/main.c index 5efa25f4c..a2bc4cf03 100644 --- a/demos/ARMCM3-STM32F103-FATFS/main.c +++ b/demos/ARMCM3-STM32F103-FATFS/main.c @@ -216,6 +216,7 @@ static WORKING_AREA(waThread1, 128); static msg_t Thread1(void *arg) { (void)arg; + chRegSetThreadName("blinker"); while (TRUE) { palTogglePad(IOPORT3, GPIOC_LED); if (fs_ready) -- cgit v1.2.3