diff options
Diffstat (limited to 'nuttx/configs/stm3210e-eval/src/up_buttons.c')
-rw-r--r-- | nuttx/configs/stm3210e-eval/src/up_buttons.c | 16 |
1 files changed, 13 insertions, 3 deletions
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); } } |