summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-04-16 13:40:42 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-04-16 13:40:42 +0000
commitbde61f220627b0fac9de0da322f0354675a6ef47 (patch)
treeeedca0d0ac02ea61d43a47f386bae156664a4c57 /firmware
parentfeef1ed07690c5b027e441d1ffdc381d8e71038c (diff)
ident properly
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@102 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/button.c132
1 files changed, 69 insertions, 63 deletions
diff --git a/firmware/button.c b/firmware/button.c
index 2bea49879c..bedd294606 100644
--- a/firmware/button.c
+++ b/firmware/button.c
@@ -61,20 +61,20 @@ static int count; /* Number of calls button has been down */
void button_init()
{
#ifndef SIMULATOR
- /* Set PB4 and PB8 as input pins */
- PBCR1 &= 0xfffc; /* PB8MD = 00 */
- PBCR2 &= 0xfcff; /* PB4MD = 00 */
- PBIOR &= ~(PBDR_BTN_ON|PBDR_BTN_OFF); /* Inputs */
+ /* Set PB4 and PB8 as input pins */
+ PBCR1 &= 0xfffc; /* PB8MD = 00 */
+ PBCR2 &= 0xfcff; /* PB4MD = 00 */
+ PBIOR &= ~(PBDR_BTN_ON|PBDR_BTN_OFF); /* Inputs */
- /* Set A/D to scan AN4 and AN5.
- * This needs to be changed to scan other analog pins
- * for battery level, etc. */
- ADCSR = 0;
- ADCR = 0;
- ADCSR = ADCSR_ADST | ADCSR_SCAN | 0x5;
+ /* Set A/D to scan AN4 and AN5.
+ * This needs to be changed to scan other analog pins
+ * for battery level, etc. */
+ ADCSR = 0;
+ ADCR = 0;
+ ADCSR = ADCSR_ADST | ADCSR_SCAN | 0x5;
#endif
- last = BUTTON_NONE;
- count = 0;
+ last = BUTTON_NONE;
+ count = 0;
}
/*
@@ -82,36 +82,36 @@ void button_init()
*/
static int get_raw_button (void)
{
- /* Check port B pins for ON and OFF */
- int data = PBDR;
- if ((data & PBDR_BTN_ON) == 0)
- return BUTTON_ON;
- else if ((data & PBDR_BTN_OFF) == 0)
- return BUTTON_OFF;
-
- /* Check AN4 pin for F1-3 and UP */
- data = ADDRAH;
- if (data >= LEVEL4)
- return BUTTON_F3;
- else if (data >= LEVEL3)
- return BUTTON_UP;
- else if (data >= LEVEL2)
- return BUTTON_F2;
- else if (data >= LEVEL1)
- return BUTTON_F1;
-
- /* Check AN5 pin for DOWN, PLAY, LEFT, RIGHT */
- data = ADDRBH;
- if (data >= LEVEL4)
- return BUTTON_DOWN;
- else if (data >= LEVEL3)
- return BUTTON_PLAY;
- else if (data >= LEVEL2)
- return BUTTON_LEFT;
- else if (data >= LEVEL1)
- return BUTTON_RIGHT;
+ /* Check port B pins for ON and OFF */
+ int data = PBDR;
+ if ((data & PBDR_BTN_ON) == 0)
+ return BUTTON_ON;
+ else if ((data & PBDR_BTN_OFF) == 0)
+ return BUTTON_OFF;
+
+ /* Check AN4 pin for F1-3 and UP */
+ data = ADDRAH;
+ if (data >= LEVEL4)
+ return BUTTON_F3;
+ else if (data >= LEVEL3)
+ return BUTTON_UP;
+ else if (data >= LEVEL2)
+ return BUTTON_F2;
+ else if (data >= LEVEL1)
+ return BUTTON_F1;
+
+ /* Check AN5 pin for DOWN, PLAY, LEFT, RIGHT */
+ data = ADDRBH;
+ if (data >= LEVEL4)
+ return BUTTON_DOWN;
+ else if (data >= LEVEL3)
+ return BUTTON_PLAY;
+ else if (data >= LEVEL2)
+ return BUTTON_LEFT;
+ else if (data >= LEVEL1)
+ return BUTTON_RIGHT;
- return BUTTON_NONE;
+ return BUTTON_NONE;
}
/*
@@ -123,29 +123,35 @@ static int get_raw_button (void)
*/
int button_get(void)
{
- int btn = get_raw_button();
- int ret;
-
- /* Last button pressed is still down */
- if (btn != BUTTON_NONE && btn == last) {
- count++;
- if (count == BOUNCE_COUNT)
- return btn;
- else if (count >= HOLD_COUNT)
- return btn | BUTTON_HELD;
+ int btn = get_raw_button();
+ int ret;
+
+ /* Last button pressed is still down */
+ if (btn != BUTTON_NONE && btn == last) {
+ count++;
+ if (count == BOUNCE_COUNT)
+ return btn;
+ else if (count >= HOLD_COUNT)
+ return btn | BUTTON_HELD;
+ else
+ return BUTTON_NONE;
+ }
+
+ /* Last button pressed now released */
+ if (btn == BUTTON_NONE && last != BUTTON_NONE)
+ ret = last | BUTTON_REL;
else
- return BUTTON_NONE;
- }
-
- /* Last button pressed now released */
- if (btn == BUTTON_NONE && last != BUTTON_NONE)
- ret = last | BUTTON_REL;
- else
- ret = BUTTON_NONE;
-
- last = btn;
- count = 0;
- return ret;
+ ret = BUTTON_NONE;
+
+ last = btn;
+ count = 0;
+ return ret;
}
#endif /* HAVE_RECORDER_KEYPAD */
+
+/* -----------------------------------------------------------------
+ * local variables:
+ * eval: (load-file "rockbox-mode.el")
+ * end:
+ */