diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-07-07 16:20:35 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-07-07 16:20:35 +0000 |
commit | 21de300584601f990c440757197097746fa40034 (patch) | |
tree | db07761a3cee55d5c466a67261f0da23d73e8c96 /nuttx/configs/stm3210e-eval/src/up_buttons.c | |
parent | 6aaedb5fc741627830baa841728c504b62e047a6 (diff) | |
download | px4-nuttx-21de300584601f990c440757197097746fa40034.tar.gz px4-nuttx-21de300584601f990c440757197097746fa40034.tar.bz2 px4-nuttx-21de300584601f990c440757197097746fa40034.zip |
Add support for STM3210E-EVAL button interrupts
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3750 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/stm3210e-eval/src/up_buttons.c')
-rw-r--r-- | nuttx/configs/stm3210e-eval/src/up_buttons.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/nuttx/configs/stm3210e-eval/src/up_buttons.c b/nuttx/configs/stm3210e-eval/src/up_buttons.c index d2f68de80..9803b604c 100644 --- a/nuttx/configs/stm3210e-eval/src/up_buttons.c +++ b/nuttx/configs/stm3210e-eval/src/up_buttons.c @@ -53,10 +53,13 @@ /**************************************************************************** * Private Data ****************************************************************************/ +/* Pin configuration for each STM3210E-EVAL button. This array is indexed by + * the BUTTON_* and JOYSTICK_* definitions in board.h + */ static const uint16_t g_buttons[NUM_BUTTONS] = { - GPIO_BTN_WAKEUP, GPIO_BTN_TAMPER, GPIO_BTN_KEY, GPIO_JOY_KEY, + GPIO_BTN_WAKEUP, GPIO_BTN_TAMPER, GPIO_BTN_KEY, GPIO_JOY_SEL, GPIO_JOY_DOWN, GPIO_JOY_LEFT, GPIO_JOY_RIGHT, GPIO_JOY_UP }; @@ -70,6 +73,13 @@ static const uint16_t g_buttons[NUM_BUTTONS] = /**************************************************************************** * Name: up_buttoninit + * + * Description: + * up_buttoninit() must be called to initialize button resources. After + * that, up_buttons() may be called to collect the current state of all + * buttons or up_irqbutton() may be called to register button interrupt + * handlers. + * ****************************************************************************/ void up_buttoninit(void) @@ -110,4 +120,41 @@ uint8_t up_buttons(void) return ret; } +/************************************************************************************ + * Button support. + * + * Description: + * up_buttoninit() must be called to initialize button resources. After + * that, up_buttons() may be called to collect the current state of all + * buttons or up_irqbutton() may be called to register button interrupt + * handlers. + * + * 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. See the BUTTON_*_BIT and JOYSTICK_*_BIT + * definitions in board.h for the meaning of each bit. + * + * up_irqbutton() may be called to register an interrupt handler that will + * be called when a button is depressed or released. The ID value is a + * button enumeration value that uniquely identifies a button resource. See the + * BUTTON_* and JOYSTICK_* definitions in board.h for the meaning of enumeration + * value. The previous interrupt handler address is returned (so that it may + * restored, if so desired). + * + ************************************************************************************/ + +#ifdef CONFIG_ARCH_IRQBUTTONS +xcpt_t up_irqbutton(int id, xcpt_t irqhandler) +{ + xcpt_t oldhandler = NULL; + + /* The following should be atomic */ + + if (id >= MIN_IRQBUTTON && id <= MAX_IRQBUTTON) + { + oldhandler = stm32_gpiosetevent(g_buttons[id], true, true, true, irqhandler); + } + return oldhandler; +} +#endif #endif /* CONFIG_ARCH_BUTTONS */ |