diff options
author | Andrew Ryabinin <ryabinin.a.a@gmail.com> | 2012-12-29 00:19:23 +0400 |
---|---|---|
committer | Andrew Ryabinin <ryabinin.a.a@gmail.com> | 2012-12-29 00:19:23 +0400 |
commit | 97250a0156acda59575330575648062a7ccab689 (patch) | |
tree | 14a9e45fdf3416c157f506bdf300f48285199e68 /firmware/target/arm/rk27xx/hm60x | |
parent | 362ade3892f40ee1b0360f3af1ab013a6ef32e5e (diff) | |
download | rockbox-97250a0156acda59575330575648062a7ccab689.tar.gz rockbox-97250a0156acda59575330575648062a7ccab689.zip |
hm60x/hm801: Add hold button support.
Change-Id: I05557ecfbf0bd821d8966862a38f7f22656b36ef
Diffstat (limited to 'firmware/target/arm/rk27xx/hm60x')
-rw-r--r-- | firmware/target/arm/rk27xx/hm60x/button-hm60x.c | 25 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/hm60x/button-target.h | 2 |
2 files changed, 27 insertions, 0 deletions
diff --git a/firmware/target/arm/rk27xx/hm60x/button-hm60x.c b/firmware/target/arm/rk27xx/hm60x/button-hm60x.c index af31e78133..dfd209ceed 100644 --- a/firmware/target/arm/rk27xx/hm60x/button-hm60x.c +++ b/firmware/target/arm/rk27xx/hm60x/button-hm60x.c | |||
@@ -23,15 +23,40 @@ | |||
23 | #include "system.h" | 23 | #include "system.h" |
24 | #include "button.h" | 24 | #include "button.h" |
25 | #include "adc.h" | 25 | #include "adc.h" |
26 | #include "backlight.h" | ||
26 | 27 | ||
27 | void button_init_device(void) { | 28 | void button_init_device(void) { |
28 | /* setup button gpio as input */ | 29 | /* setup button gpio as input */ |
29 | GPIO_PCCON &= ~(POWEROFF_BUTTON); | 30 | GPIO_PCCON &= ~(POWEROFF_BUTTON); |
31 | GPIO_PACON &= ~(1); | ||
32 | |||
33 | /* setup button gpio as pulldown */ | ||
34 | SCU_GPIOUPCON |= (1<<17) | | ||
35 | 1 ; | ||
36 | } | ||
37 | |||
38 | bool button_hold() { | ||
39 | return (GPIO_PADR & 1); | ||
30 | } | 40 | } |
31 | 41 | ||
32 | int button_read_device(void) { | 42 | int button_read_device(void) { |
33 | int adc_val = adc_read(ADC_BUTTONS); | 43 | int adc_val = adc_read(ADC_BUTTONS); |
34 | int gpio_btn = GPIO_PCDR & BUTTON_POWER; | 44 | int gpio_btn = GPIO_PCDR & BUTTON_POWER; |
45 | static bool hold_button = false; | ||
46 | bool hold_button_old; | ||
47 | |||
48 | hold_button_old = hold_button; | ||
49 | hold_button = button_hold(); | ||
50 | |||
51 | #ifndef BOOTLOADER | ||
52 | if (hold_button != hold_button_old) { | ||
53 | backlight_hold_changed(hold_button); | ||
54 | } | ||
55 | #endif | ||
56 | |||
57 | if (hold_button) { | ||
58 | return 0; | ||
59 | } | ||
35 | 60 | ||
36 | if (adc_val < 380) { /* 0 - 379 */ | 61 | if (adc_val < 380) { /* 0 - 379 */ |
37 | if (adc_val < 250) { /* 0 - 249 */ | 62 | if (adc_val < 250) { /* 0 - 249 */ |
diff --git a/firmware/target/arm/rk27xx/hm60x/button-target.h b/firmware/target/arm/rk27xx/hm60x/button-target.h index ff4c9423b3..b6950b52de 100644 --- a/firmware/target/arm/rk27xx/hm60x/button-target.h +++ b/firmware/target/arm/rk27xx/hm60x/button-target.h | |||
@@ -21,6 +21,8 @@ | |||
21 | #ifndef _BUTTON_TARGET_H_ | 21 | #ifndef _BUTTON_TARGET_H_ |
22 | #define _BUTTON_TARGET_H_ | 22 | #define _BUTTON_TARGET_H_ |
23 | 23 | ||
24 | #define HAS_BUTTON_HOLD | ||
25 | |||
24 | #define BUTTON_UP 0x00000001 | 26 | #define BUTTON_UP 0x00000001 |
25 | #define BUTTON_POWER 0x00000002 | 27 | #define BUTTON_POWER 0x00000002 |
26 | #define BUTTON_DOWN 0x00000004 | 28 | #define BUTTON_DOWN 0x00000004 |