summaryrefslogtreecommitdiff
path: root/firmware/target/sh/archos/fm_v2/button-fm_v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/sh/archos/fm_v2/button-fm_v2.c')
-rw-r--r--firmware/target/sh/archos/fm_v2/button-fm_v2.c99
1 files changed, 0 insertions, 99 deletions
diff --git a/firmware/target/sh/archos/fm_v2/button-fm_v2.c b/firmware/target/sh/archos/fm_v2/button-fm_v2.c
deleted file mode 100644
index 458917d2d5..0000000000
--- a/firmware/target/sh/archos/fm_v2/button-fm_v2.c
+++ /dev/null
@@ -1,99 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "system.h"
24#include "button.h"
25#include "backlight.h"
26#include "adc.h"
27
28/*
29 Recorder FM/V2 hardware button hookup
30 =====================================
31
32 F1, F2, F3, UP: connected to AN4 through a resistor network
33 DOWN, PLAY, LEFT, RIGHT: likewise connected to AN5
34
35 The voltage on AN4/ AN5 depends on which keys (or key combo) is pressed
36 FM/V2 has PLAY and RIGHT switched compared to plain recorder
37
38 ON: AN3, low active
39 OFF: AN2, high active
40*/
41
42void button_init_device(void)
43{
44 /* Set PB4 and PB8 as input pins */
45 PBCR1 &= 0xfffc; /* PB8MD = 00 */
46 PBCR2 &= 0xfcff; /* PB4MD = 00 */
47 PBIOR &= ~0x0110; /* Inputs */
48}
49
50int button_read_device(void)
51{
52 int btn = BUTTON_NONE;
53 int data;
54
55 /* check F1..F3 and UP */
56 data = adc_read(ADC_BUTTON_ROW1);
57 if (data >= 150)
58 {
59 if (data >= 545)
60 if (data >= 700)
61 btn = BUTTON_F3;
62 else
63 btn = BUTTON_UP;
64 else
65 if (data >= 385)
66 btn = BUTTON_F2;
67 else
68 btn = BUTTON_F1;
69 }
70
71 /* Some units have mushy keypads, so pressing UP also activates
72 the Left/Right buttons. Let's combat that by skipping the AN5
73 checks when UP is pressed. */
74 if(!(btn & BUTTON_UP))
75 {
76 /* check DOWN, PLAY, LEFT, RIGHT */
77 data = adc_read(ADC_BUTTON_ROW2);
78 if (data >= 150)
79 {
80 if (data >= 545)
81 if (data >= 700)
82 btn |= BUTTON_DOWN;
83 else
84 btn |= BUTTON_RIGHT;
85 else
86 if (data >= 385)
87 btn |= BUTTON_LEFT;
88 else
89 btn |= BUTTON_PLAY;
90 }
91 }
92
93 if ( adc_read(ADC_BUTTON_ON) < 512 )
94 btn |= BUTTON_ON;
95 if ( adc_read(ADC_BUTTON_OFF) > 512 )
96 btn |= BUTTON_OFF;
97
98 return btn;
99}