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 | |
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')
-rw-r--r-- | firmware/target/arm/rk27xx/hm60x/button-hm60x.c | 25 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/hm60x/button-target.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/hm801/button-hm801.c | 27 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/hm801/button-target.h | 2 |
4 files changed, 55 insertions, 1 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 |
diff --git a/firmware/target/arm/rk27xx/hm801/button-hm801.c b/firmware/target/arm/rk27xx/hm801/button-hm801.c index d0323e6f4d..0ac1b3b0aa 100644 --- a/firmware/target/arm/rk27xx/hm801/button-hm801.c +++ b/firmware/target/arm/rk27xx/hm801/button-hm801.c | |||
@@ -23,6 +23,7 @@ | |||
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 | enum keyboard_type_t { | 28 | enum keyboard_type_t { |
28 | KEYBOARD_V1, | 29 | KEYBOARD_V1, |
@@ -34,6 +35,12 @@ static enum keyboard_type_t kbd_type; | |||
34 | void button_init_device(void) { | 35 | void button_init_device(void) { |
35 | /* setup button gpio as input */ | 36 | /* setup button gpio as input */ |
36 | GPIO_PCCON &= ~(POWEROFF_BUTTON); | 37 | GPIO_PCCON &= ~(POWEROFF_BUTTON); |
38 | GPIO_PACON &= ~1; | ||
39 | |||
40 | |||
41 | /* setup button gpio as pulldown */ | ||
42 | SCU_GPIOUPCON |= (1<<17) | | ||
43 | 1 ; | ||
37 | 44 | ||
38 | /* identify keyboard type */ | 45 | /* identify keyboard type */ |
39 | SCU_IOMUXB_CON &= ~(1<<2); | 46 | SCU_IOMUXB_CON &= ~(1<<2); |
@@ -45,6 +52,10 @@ void button_init_device(void) { | |||
45 | } | 52 | } |
46 | } | 53 | } |
47 | 54 | ||
55 | bool button_hold() { | ||
56 | return (GPIO_PADR & 1); | ||
57 | } | ||
58 | |||
48 | static int button_read_device_v1(void) { | 59 | static int button_read_device_v1(void) { |
49 | int adc_val = adc_read(ADC_BUTTONS); | 60 | int adc_val = adc_read(ADC_BUTTONS); |
50 | int button = 0; | 61 | int button = 0; |
@@ -125,7 +136,21 @@ static int button_read_device_v2(void) { | |||
125 | } | 136 | } |
126 | 137 | ||
127 | int button_read_device(void) { | 138 | int button_read_device(void) { |
128 | if (kbd_type == KEYBOARD_V1) { | 139 | static bool hold_button = false; |
140 | bool hold_button_old; | ||
141 | |||
142 | hold_button_old = hold_button; | ||
143 | hold_button = button_hold(); | ||
144 | |||
145 | #ifndef BOOTLOADER | ||
146 | if (hold_button != hold_button_old) { | ||
147 | backlight_hold_changed(hold_button); | ||
148 | } | ||
149 | #endif | ||
150 | |||
151 | if (hold_button) { | ||
152 | return 0; | ||
153 | } else if (kbd_type == KEYBOARD_V1) { | ||
129 | return button_read_device_v1(); | 154 | return button_read_device_v1(); |
130 | } else { | 155 | } else { |
131 | return button_read_device_v2(); | 156 | return button_read_device_v2(); |
diff --git a/firmware/target/arm/rk27xx/hm801/button-target.h b/firmware/target/arm/rk27xx/hm801/button-target.h index 7754f867e5..29c31d0df6 100644 --- a/firmware/target/arm/rk27xx/hm801/button-target.h +++ b/firmware/target/arm/rk27xx/hm801/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 |