diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-07-07 18:40:15 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-07-07 18:40:15 +0000 |
commit | b4ee6ba758d5582b6b6eb69c4cf4beaa955c5cf1 (patch) | |
tree | 9a3d520118b0193ad6eedb211b4dfd2051173c18 /nuttx | |
parent | 21de300584601f990c440757197097746fa40034 (diff) | |
download | px4-nuttx-b4ee6ba758d5582b6b6eb69c4cf4beaa955c5cf1.tar.gz px4-nuttx-b4ee6ba758d5582b6b6eb69c4cf4beaa955c5cf1.tar.bz2 px4-nuttx-b4ee6ba758d5582b6b6eb69c4cf4beaa955c5cf1.zip |
Verified STM3210E-EVAL button handling and new button test application
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3751 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/ChangeLog | 6 | ||||
-rw-r--r-- | nuttx/configs/stm3210e-eval/buttons/defconfig | 13 | ||||
-rwxr-xr-x | nuttx/configs/stm3210e-eval/src/stm3210e-internal.h | 2 | ||||
-rw-r--r-- | nuttx/configs/stm3210e-eval/src/up_buttons.c | 16 | ||||
-rw-r--r-- | nuttx/include/nuttx/arch.h | 6 |
5 files changed, 35 insertions, 8 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 362ff62e5..18afe10e8 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -1869,3 +1869,9 @@ are trying to using multiple UARTs on STM32. * configs/stm3210e-eval/src/up_lcd.c: Add a driver for the STM3210E-EVAL's LCD. * configs/stm3210e-eval/nx: Add NX configuration for the STM3210E-EVAL. + * configs/nuttx/arch.h (and arch/arm/src/stm32, configs/*/src/up_buttons.c): + Standardize interfaces exported for button support and button interrupts. + * configs/stm3210e-eval/src/up_buttons.c - Add interrupting button support. + Also fixes a few errors in STM3210E-EVAL button decoding. + * configs/stm3210e-eval/buttons: Add a configuration to exercise STM3210E-EVAL + buttons. diff --git a/nuttx/configs/stm3210e-eval/buttons/defconfig b/nuttx/configs/stm3210e-eval/buttons/defconfig index 4a072721a..ebe5d7d44 100644 --- a/nuttx/configs/stm3210e-eval/buttons/defconfig +++ b/nuttx/configs/stm3210e-eval/buttons/defconfig @@ -684,14 +684,23 @@ CONFIG_EXAMPLE_NETTEST_CLIENTIP=(10<<24|0<<16|0<<8|1) # Settings for examples/buttons # # CONFIG_EXAMPLE_BUTTONS_MIN and CONFIG_EXAMPLE_BUTTONS_MAX -# Lowest and highest button number +# Lowest and highest button number (0-7) # CONFIG_EXAMPLE_IRQBUTTONS_MIN and CONFIG_EXAMPLE_IRQBUTTONS_MAX -# Lowest and highest interrupting button number +# Lowest and highest interrupting button number (-7) +# CONFIG_EXAMPLE_BUTTONS_NAMEn - Name for button n # CONFIG_EXAMPLE_BUTTONS_MIN=0 CONFIG_EXAMPLE_BUTTONS_MAX=7 CONFIG_EXAMPLE_IRQBUTTONS_MIN=2 CONFIG_EXAMPLE_IRQBUTTONS_MAX=7 +CONFIG_EXAMPLE_BUTTONS_NAME0="WAKEUP" +CONFIG_EXAMPLE_BUTTONS_NAME1="TAMPER" +CONFIG_EXAMPLE_BUTTONS_NAME2="KEY" +CONFIG_EXAMPLE_BUTTONS_NAME3="SELECT" +CONFIG_EXAMPLE_BUTTONS_NAME4="DOWN" +CONFIG_EXAMPLE_BUTTONS_NAME5="LEFT" +CONFIG_EXAMPLE_BUTTONS_NAME6="RIGHT" +CONFIG_EXAMPLE_BUTTONS_NAME7="UP" # # Settings for examples/ostest diff --git a/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h b/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h index 8634feab8..42d3090e0 100755 --- a/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h +++ b/nuttx/configs/stm3210e-eval/src/stm3210e-internal.h @@ -83,7 +83,7 @@ #define GPIO_BTN_WAKEUP (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
GPIO_PORTA|GPIO_PIN0)
#define GPIO_BTN_TAMPER (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
- GPIO_PORTA|GPIO_PIN0)
+ GPIO_PORTC|GPIO_PIN13)
#define GPIO_BTN_KEY (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
GPIO_EXTI|GPIO_PORTG|GPIO_PIN8)
#define GPIO_JOY_SEL (GPIO_INPUT|GPIO_CNF_INFLOAT|GPIO_MODE_INPUT|\
diff --git a/nuttx/configs/stm3210e-eval/src/up_buttons.c b/nuttx/configs/stm3210e-eval/src/up_buttons.c index 9803b604c..b9c9fb9d4 100644 --- a/nuttx/configs/stm3210e-eval/src/up_buttons.c +++ b/nuttx/configs/stm3210e-eval/src/up_buttons.c @@ -109,11 +109,21 @@ uint8_t up_buttons(void) for (i = 0; i < NUM_BUTTONS; i++) { - /* A LOW value means that the key is pressed */ + /* A LOW value means that the key is pressed for most keys. The exception + * is the WAKEUP button. + */ - if (!stm32_gpioread(g_buttons[i])) + bool released = stm32_gpioread(g_buttons[i]); + if (i == BUTTON_WAKEUP) { - ret |= (1 << i); + released = !released; + } + + /* Accumulate the set of depressed (not released) keys */ + + if (!released) + { + ret |= (1 << i); } } diff --git a/nuttx/include/nuttx/arch.h b/nuttx/include/nuttx/arch.h index 5bc3980aa..3a4dedfa3 100644 --- a/nuttx/include/nuttx/arch.h +++ b/nuttx/include/nuttx/arch.h @@ -560,8 +560,10 @@ EXTERN void up_buttoninit(void); * Description: * After up_buttoninit() has been called, up_buttons() may be called to * collect the state of all buttons. up_buttons() returns an 8-bit bit set - * with each bit associated with a button. The meaning of the each button - * bit is board-specific. + * with each bit associated with a button. A bit set to "1" means that the + * button is depressed; a bit set to "0" means that the button is released. + * The correspondence of the each button bit and physical buttons is board- + * specific. * * NOTE: This interface may or may not be supported by board-specific * logic. If the board supports button interfaces, then CONFIG_ARCH_BUTTONS |