diff options
author | Andrew Ryabinin <ryabinin.a.a@gmail.com> | 2011-11-03 11:53:02 +0000 |
---|---|---|
committer | Andrew Ryabinin <ryabinin.a.a@gmail.com> | 2011-11-03 11:53:02 +0000 |
commit | 2164aab9020bb37ec71a24461c4c42bc4e2eb2d3 (patch) | |
tree | dbf138f0f8d84789b335e6059508176a71fe0cde /firmware/target/arm/rk27xx/hm801/button-hm801.c | |
parent | 50211e20548bf3a5f7781489269a297cad58713e (diff) | |
download | rockbox-2164aab9020bb37ec71a24461c4c42bc4e2eb2d3.tar.gz rockbox-2164aab9020bb37ec71a24461c4c42bc4e2eb2d3.zip |
Added HiFiMAN HM-801 target. FS#12355. This also renames tda1543.{ch} used by HM-60x to dummy_codec.{ch} as it works for PCM1704 used by HM-801.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30891 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/rk27xx/hm801/button-hm801.c')
-rw-r--r-- | firmware/target/arm/rk27xx/hm801/button-hm801.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/firmware/target/arm/rk27xx/hm801/button-hm801.c b/firmware/target/arm/rk27xx/hm801/button-hm801.c new file mode 100644 index 0000000000..8e3d46bf0d --- /dev/null +++ b/firmware/target/arm/rk27xx/hm801/button-hm801.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 Andrew Ryabinin | ||
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 "adc.h" | ||
26 | |||
27 | void button_init_device(void) { | ||
28 | /* setup button gpio as input */ | ||
29 | GPIO_PCCON &= ~(POWEROFF_BUTTON); | ||
30 | } | ||
31 | |||
32 | int button_read_device(void) { | ||
33 | int adc_val = adc_read(ADC_BUTTONS); | ||
34 | int button = 0; | ||
35 | |||
36 | if (adc_val < 480) { /* middle */ | ||
37 | if (adc_val < 200) { /* 200 - 0 */ | ||
38 | if (adc_val < 30) { | ||
39 | button = BUTTON_UP; | ||
40 | } else { | ||
41 | button = BUTTON_RIGHT; /* 30 - 200 */ | ||
42 | } | ||
43 | } else { /* 200 - 480 */ | ||
44 | if (adc_val < 370) { | ||
45 | button = BUTTON_SELECT; | ||
46 | } else { | ||
47 | button = BUTTON_DOWN; | ||
48 | } | ||
49 | } | ||
50 | } else { /* > 480 */ | ||
51 | if (adc_val < 690) { /* 480 - 690 */ | ||
52 | if (adc_val < 580) { | ||
53 | button = BUTTON_LEFT; | ||
54 | } else { | ||
55 | button = BUTTON_NEXT; | ||
56 | } | ||
57 | } else { /* > 680 */ | ||
58 | if (adc_val < 840) { | ||
59 | button = BUTTON_PREV; | ||
60 | } else { | ||
61 | if (adc_val < 920) { | ||
62 | button = BUTTON_PLAY; | ||
63 | } | ||
64 | } | ||
65 | } | ||
66 | } | ||
67 | return button | (GPIO_PCDR & POWEROFF_BUTTON); | ||
68 | } | ||