Updates to the CC3000 example from David Sidrane

This commit is contained in:
Gregory Nutt 2013-10-30 14:23:45 -06:00
parent 608b605f40
commit 253ab48071
4 changed files with 32 additions and 18 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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> "