projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: Remove spurious ao_mma655x_spi_index variable
[fw/altos]
/
src
/
cc1111
/
ao_button.c
diff --git
a/src/cc1111/ao_button.c
b/src/cc1111/ao_button.c
index 77a8dde8b6918f4bbaeb49e7b4199d0c2b20ef84..0496a32f270454b95935017896c318eec98482bc 100644
(file)
--- a/
src/cc1111/ao_button.c
+++ b/
src/cc1111/ao_button.c
@@
-3,7
+3,8
@@
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-36,11
+37,17
@@
static __code struct {
#define NUM_BUTTONS ((sizeof ao_buttons) / sizeof (ao_buttons[0]))
#define NUM_BUTTONS ((sizeof ao_buttons) / sizeof (ao_buttons[0]))
+static __xdata uint16_t ao_button_tick[NUM_BUTTONS];
+
static void
ao_button_insert(char n)
{
static void
ao_button_insert(char n)
{
- ao_fifo_insert(ao_button_fifo, n);
- ao_wakeup(&ao_button_fifo);
+ uint16_t now = ao_time();
+ if ((now - ao_button_tick[n]) > 20) {
+ ao_button_tick[n] = now;
+ ao_fifo_insert(ao_button_fifo, n);
+ ao_wakeup(&ao_button_fifo);
+ }
}
static void
}
static void
@@
-66,17
+73,26
@@
ao_button_mask(uint8_t reg)
}
char
}
char
-ao_button_get(
void
) __critical
+ao_button_get(
uint16_t timeout
) __critical
{
char b;
while (ao_fifo_empty(ao_button_fifo))
{
char b;
while (ao_fifo_empty(ao_button_fifo))
- if (ao_sleep
(&ao_button_fifo
))
+ if (ao_sleep
_for(&ao_button_fifo, timeout
))
return 0;
ao_fifo_remove(ao_button_fifo, b);
return b;
}
return 0;
ao_fifo_remove(ao_button_fifo, b);
return b;
}
+void
+ao_button_clear(void) __critical
+{
+ char b;
+
+ while (!ao_fifo_empty(ao_button_fifo))
+ ao_fifo_remove(ao_button_fifo, b);
+}
+
void
ao_p0_isr(void) ao_arch_interrupt(13)
{
void
ao_p0_isr(void) ao_arch_interrupt(13)
{