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
This commit is contained in:
patacongo 2011-07-07 18:40:15 +00:00
parent c8fdd79b5b
commit f6295e31ae
3 changed files with 25 additions and 6 deletions

View File

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

View File

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

View File

@ -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);
}
}