summaryrefslogtreecommitdiff
path: root/apps/examples
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-10-30 14:23:45 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-10-30 14:23:45 -0600
commit03ed8828a9ab9714402df1d9cc019f8c1bcc55b5 (patch)
tree92fb5634f52b54d63f35c08b82f2c7a20155b643 /apps/examples
parent9c190bae9b5d3082d156626dc7c741691a3338cd (diff)
downloadpx4-nuttx-03ed8828a9ab9714402df1d9cc019f8c1bcc55b5.tar.gz
px4-nuttx-03ed8828a9ab9714402df1d9cc019f8c1bcc55b5.tar.bz2
px4-nuttx-03ed8828a9ab9714402df1d9cc019f8c1bcc55b5.zip
Updates to the CC3000 example from David Sidrane
Diffstat (limited to 'apps/examples')
-rw-r--r--apps/examples/cc3000/Kconfig13
-rw-r--r--apps/examples/cc3000/cc3000basic.c29
-rw-r--r--apps/examples/cc3000/shell.c4
-rw-r--r--apps/examples/cc3000/shell.h4
4 files changed, 32 insertions, 18 deletions
diff --git a/apps/examples/cc3000/Kconfig b/apps/examples/cc3000/Kconfig
index 505086336..93ab8a589 100644
--- a/apps/examples/cc3000/Kconfig
+++ b/apps/examples/cc3000/Kconfig
@@ -11,4 +11,17 @@ config EXAMPLES_CC3000BASIC
Enable the CC3000BASIC example
if EXAMPLES_CC3000BASIC
+
+config EXAMPLES_CC3000_MEM_CHECK
+ bool "Memory check instrumentation"
+ default n
+ ---help---
+ Define to help debug memory issues
+
+config EXAMPLES_CC3000_STACK_CHECK
+ bool "Stack check instrumentation"
+ default n
+ ---help---
+ Define to help debug stack size issues
+
endif
diff --git a/apps/examples/cc3000/cc3000basic.c b/apps/examples/cc3000/cc3000basic.c
index 1a4d12714..7ac4fa139 100644
--- a/apps/examples/cc3000/cc3000basic.c
+++ b/apps/examples/cc3000/cc3000basic.c
@@ -145,17 +145,13 @@ void ShowInformation(void);
#define US_PER_MS 1000
#define US_PER_SEC 1000000
-/* Define to help debug stack size issues */
-
-#undef CONFIG_EXAMPLE_CC3000_MEM_CHECK
-
/****************************************************************************
* Private Data
****************************************************************************/
static uint8_t isInitialized = false;
-#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+#ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK
static struct mallinfo mmstart;
static struct mallinfo mmprevious;
#endif
@@ -164,7 +160,7 @@ static struct mallinfo mmprevious;
* Private Functions
****************************************************************************/
-#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+#ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK
static void show_memory_usage(struct mallinfo *mmbefore,
struct mallinfo *mmafter)
{
@@ -186,14 +182,21 @@ static void show_memory_usage(struct mallinfo *mmbefore,
printf("Change:%11d freed\n", diff);
}
+#ifdef CONFIG_EXAMPLES_CC3000_STACK_CHECK
stkmon_disp();
+#endif
}
+#endif
+#ifdef CONFIG_EXAMPLES_CC3000_STACK_CHECK
+static char buff[CONFIG_TASK_NAME_SIZE+1];
static void _stkmon_disp(FAR struct tcb_s *tcb, FAR void *arg)
{
#if CONFIG_TASK_NAME_SIZE > 0
+ strncpy(buff,tcb->name,CONFIG_TASK_NAME_SIZE);
+ buff[CONFIG_TASK_NAME_SIZE] = '\0';
syslog("%5d %6d %6d %s\n",
- tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb), tcb->name);
+ tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb), buff);
#else
syslog("%5d %6d %6d\n",
tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb));
@@ -247,7 +250,7 @@ static bool wait_on(long timeoutMs, volatile unsigned long *what,
* Public Functions
****************************************************************************/
-#ifndef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+#ifndef CONFIG_EXAMPLES_CC3000_STACK_CHECK
# define stkmon_disp()
#else
void stkmon_disp(void)
@@ -369,12 +372,12 @@ int execute(int cmd)
Initialize();
}
-#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+#ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK
mmprevious= mallinfo();
show_memory_usage(&mmstart,&mmprevious);
#endif
shell_main(0, 0);
-#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+#ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK
mmprevious= mallinfo();
show_memory_usage(&mmstart,&mmprevious);
#endif
@@ -395,7 +398,7 @@ int execute(int cmd)
void Initialize(void)
{
-#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+#ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK
mmstart = mallinfo();
memcpy(&mmprevious, &mmstart, sizeof(struct mallinfo));
show_memory_usage(&mmstart,&mmprevious);
@@ -412,7 +415,7 @@ void Initialize(void)
printf("Initializing CC3000...\n");
CC3000_Init();
-#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+#ifdef CONFIG_EXAMPLES_CC3000_STACK_CHECK
stkmon_disp();
#endif
printf(" CC3000 init complete.\n");
@@ -454,7 +457,7 @@ void Initialize(void)
isInitialized = true;
#endif
-#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+#ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK
mmprevious = mallinfo();
show_memory_usage(&mmstart,&mmprevious);
#endif
diff --git a/apps/examples/cc3000/shell.c b/apps/examples/cc3000/shell.c
index 2e8f3d08d..9678863e0 100644
--- a/apps/examples/cc3000/shell.c
+++ b/apps/examples/cc3000/shell.c
@@ -122,7 +122,7 @@ static void shell_unknown(int argc, char **argv)
static void shell_quit(int argc, char **argv)
{
printf("Bye!\n");
-#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+#ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK
stkmon_disp();
#endif
exit(0);
@@ -167,7 +167,7 @@ int shell_session(int argc, char *argv[])
printf("CC3000 command shell -- NuttX style\n");
printf("Type '?' and return for help\n");
-#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
+#ifdef CONFIG_EXAMPLES_CC3000_MEM_CHECK
stkmon_disp();
#endif
diff --git a/apps/examples/cc3000/shell.h b/apps/examples/cc3000/shell.h
index c6ad0422c..b247c993c 100644
--- a/apps/examples/cc3000/shell.h
+++ b/apps/examples/cc3000/shell.h
@@ -67,11 +67,9 @@
#endif
#ifndef CONFIG_EXAMPLES_TELNETD_CLIENTSTACKSIZE
-# define CONFIG_EXAMPLES_TELNETD_CLIENTSTACKSIZE 864
+# define CONFIG_EXAMPLES_TELNETD_CLIENTSTACKSIZE 894
#endif
-#undef CONFIG_EXAMPLE_CC3000_MEM_CHECK
-
/* Other definitions ********************************************************/
#define SHELL_PROMPT "CC3000 1.0> "