diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-11-14 14:45:30 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-11-14 14:45:30 +0000 |
commit | c5c3f5ad84cce90b89cff4d88334789c2bc2e2f9 (patch) | |
tree | 5e3bd37f24bb5ccb1f3ad5b5192d9beff1df8242 | |
parent | 9680f958408f49a75ea7b49dade839e72937a074 (diff) | |
download | px4-nuttx-c5c3f5ad84cce90b89cff4d88334789c2bc2e2f9.tar.gz px4-nuttx-c5c3f5ad84cce90b89cff4d88334789c2bc2e2f9.tar.bz2 px4-nuttx-c5c3f5ad84cce90b89cff4d88334789c2bc2e2f9.zip |
Button test can now be built as an NSH command
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4091 42af7a65-404d-4744-a932-0658087f49c3
-rwxr-xr-x | apps/ChangeLog.txt | 5 | ||||
-rw-r--r-- | apps/examples/buttons/Makefile | 16 | ||||
-rw-r--r-- | apps/examples/buttons/main.c | 68 | ||||
-rw-r--r-- | apps/examples/touchscreen/Makefile | 2 | ||||
-rw-r--r-- | nuttx/ChangeLog | 2 | ||||
-rw-r--r-- | nuttx/Documentation/NuttX.html | 4 | ||||
-rw-r--r-- | nuttx/ReleaseNotes | 4 |
7 files changed, 88 insertions, 13 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index d8c796a67..b808df67a 100755 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -127,6 +127,9 @@ 6.11 2011-11-12 Gregory Nutt <gnutt@nuttx.org> - (No major changes from 6.10) + (No major changes from 6.10) 6.12 2011-xx-xx Gregory Nutt <gnutt@nuttx.org> + + * apps/examples/buttons: The button test can now be executed as an NSH + built in command. diff --git a/apps/examples/buttons/Makefile b/apps/examples/buttons/Makefile index 89db5cec1..9c0587199 100644 --- a/apps/examples/buttons/Makefile +++ b/apps/examples/buttons/Makefile @@ -56,12 +56,18 @@ endif ROOTDEPPATH = --dep-path . +# Buttons built-in application info + +APPNAME = buttons +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 + # Common build VPATH = all: .built -.PHONY: clean depend distclean +.PHONY: context clean depend distclean $(AOBJS): %$(OBJEXT): %.S $(call ASSEMBLE, $<, $@) @@ -75,7 +81,13 @@ $(COBJS): %$(OBJEXT): %.c done ; ) @touch .built -context: +.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + @touch $@ +endif + +context: .context .depend: Makefile $(SRCS) @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep diff --git a/apps/examples/buttons/main.c b/apps/examples/buttons/main.c index 43999bc1a..b0d06e48a 100644 --- a/apps/examples/buttons/main.c +++ b/apps/examples/buttons/main.c @@ -48,6 +48,7 @@ #include <nuttx/arch.h> #include <stdio.h> +#include <stdlib.h> #include <unistd.h> #include <debug.h> @@ -129,6 +130,16 @@ #define NUM_BUTTONS (MAX_BUTTON - MIN_BUTTON + 1) #define BUTTON_INDEX(b) ((b)-MIN_BUTTON) +/* Is this being built as an NSH built-in application? */ + +#ifdef CONFIG_NSH_BUILTIN_APPS +# define MAIN_NAME buttons_main +# define MAIN_STRING "buttons_main: " +#else +# define MAIN_NAME user_start +# define MAIN_STRING "user_start: " +#endif + /**************************************************************************** * Private Types ****************************************************************************/ @@ -254,8 +265,14 @@ static const struct button_info_s g_buttoninfo[NUM_BUTTONS] = static uint8_t g_oldset; +/* Used to limit the number of button presses */ + +#ifdef CONFIG_NSH_BUILTIN_APPS +static volatile long g_nbuttons; +#endif + /**************************************************************************** - * Public Functions + * Private Functions ****************************************************************************/ static void show_buttons(uint8_t oldset, uint8_t newset) @@ -263,6 +280,17 @@ static void show_buttons(uint8_t oldset, uint8_t newset) uint8_t chgset = oldset ^ newset; int i; + /* Update the count of button presses shown */ + +#ifdef CONFIG_NSH_BUILTIN_APPS + if ((chgset & newset) != 0) + { + g_nbuttons++; + } +#endif + + /* Show each button state change */ + for (i = MIN_BUTTON; i <= MAX_BUTTON; i++) { uint8_t mask = (1 << i); @@ -295,7 +323,7 @@ static void button_handler(int id, int irq) { uint8_t newset = up_buttons(); - lib_lowprintf("IRQ:%d Button %d:%s IRQ:%d SET:%02x:\n", + lib_lowprintf("IRQ:%d Button %d:%s SET:%02x:\n", irq, id, g_buttoninfo[BUTTON_INDEX(id)].name, newset); show_buttons(g_oldset, newset); g_oldset = newset; @@ -367,15 +395,33 @@ static int button7_handler(int irq, FAR void *context) #endif /* CONFIG_ARCH_IRQBUTTONS */ /**************************************************************************** - * user_start + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * user_start/buttons_main ****************************************************************************/ -int user_start(int argc, char *argv[]) +int MAIN_NAME(int argc, char *argv[]) { uint8_t newset; irqstate_t flags; int i; + /* If this example is configured as an NX add-on, then limit the number of + * samples that we collect before returning. Otherwise, we never return + */ + +#ifdef CONFIG_NSH_BUILTIN_APPS + long maxbuttons = 1; + g_nbuttons = 0; + if (argc > 1) + { + maxbuttons = strtol(argv[1], NULL, 10); + } + lib_lowprintf("maxbuttons: %d\n", maxbuttons); +#endif + /* Register to recieve button interrupts */ #ifdef CONFIG_ARCH_IRQBUTTONS @@ -408,7 +454,11 @@ int user_start(int argc, char *argv[]) /* Poll button state */ g_oldset = up_buttons(); +#ifdef CONFIG_NSH_BUILTIN_APPS + while (g_nbuttons < maxbuttons) +#else for (;;) +#endif { /* Get the set of pressed and release buttons. */ @@ -440,6 +490,16 @@ int user_start(int argc, char *argv[]) usleep(150000); /* 150 Milliseconds */ } + + /* Un-register button handlers */ + +#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NSH_BUILTIN_APPS) + for (i = CONFIG_EXAMPLE_IRQBUTTONS_MIN; i <= CONFIG_EXAMPLE_IRQBUTTONS_MAX; i++) + { + (void)up_irqbutton(i, NULL); + } +#endif + return 0; } diff --git a/apps/examples/touchscreen/Makefile b/apps/examples/touchscreen/Makefile index 264a54916..e53a52cf9 100644 --- a/apps/examples/touchscreen/Makefile +++ b/apps/examples/touchscreen/Makefile @@ -56,7 +56,7 @@ endif ROOTDEPPATH = --dep-path . -# NXHELLO built-in application info +# Touchscreen built-in application info APPNAME = tc PRIORITY = SCHED_PRIORITY_DEFAULT diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index ed9670b3c..f0ace7fb4 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -2184,7 +2184,7 @@ if the block size is large, but can be common for tiny block sizes and results in a crash and file system corruption. * fs/nxffs/nxffs_initialize.c: Fix an initialize error. If the FLASH - is on power-up, NXFFS will fail to initialize correctly. + is full on power-up, NXFFS will fail to initialize correctly. * fs/nxffs/nxffs_write.c and nxffs_pack.c: Fix an error that can occur when attempt to write to FLASH volume that is completely full but has no value inodes on it. diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 870c64d09..99c6fd8ff 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -924,7 +924,7 @@ New interfaces to read from graphics memory. </li> <li><b>Drivers</b>. - The AT24xx FLASH drivers will now support clustering of blocks to achieve a larger, more usable block size for FAT. + The AT24xx FLASH driver will now supports clustering of blocks to achieve a larger, more usable block size for NXFFS. </li> <li><b>STM32</b>. LCD color corrections. @@ -2644,7 +2644,7 @@ nuttx-6.11 2011-11-12 Gregory Nutt <gnutt@nuttx.org> if the block size is large, but can be common for tiny block sizes and results in a crash and file system corruption. * fs/nxffs/nxffs_initialize.c: Fix an initialize error. If the FLASH - is on power-up, NXFFS will fail to initialize correctly. + is full on power-up, NXFFS will fail to initialize correctly. * fs/nxffs/nxffs_write.c and nxffs_pack.c: Fix an error that can occur when attempt to write to FLASH volume that is completely full but has no value inodes on it. diff --git a/nuttx/ReleaseNotes b/nuttx/ReleaseNotes index dad712a3a..4756d88bd 100644 --- a/nuttx/ReleaseNotes +++ b/nuttx/ReleaseNotes @@ -2374,8 +2374,8 @@ This release is a maintenance release that includes a few new features and some important bugfixes. New features include: * NX Graphics: New interfaces to read from graphics memory - * Drivers: AT24 FLASH drivers will now support clustering of blocks - to achieve a larger, more usable block size for FAT. + * Drivers: AT24 FLASH driver will now supports clustering of blocks + to achieve a larger, more usable block size for NXFFS. * STM32: LCD color corrections * PIC32: Board configuration for the Microchip PIC32 Ethernet Starter kit (not yet verified), new GPIO support library, button and LED support |