diff options
Diffstat (limited to 'firmware/target/arm/rk27xx/hm60x/button-hm60x.c')
-rw-r--r-- | firmware/target/arm/rk27xx/hm60x/button-hm60x.c | 25 |
1 files changed, 25 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 */ |