From 97250a0156acda59575330575648062a7ccab689 Mon Sep 17 00:00:00 2001 From: Andrew Ryabinin Date: Sat, 29 Dec 2012 00:19:23 +0400 Subject: hm60x/hm801: Add hold button support. Change-Id: I05557ecfbf0bd821d8966862a38f7f22656b36ef --- firmware/target/arm/rk27xx/hm60x/button-hm60x.c | 25 ++++++++++++++++++++++++ firmware/target/arm/rk27xx/hm60x/button-target.h | 2 ++ 2 files changed, 27 insertions(+) (limited to 'firmware/target/arm/rk27xx/hm60x') 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 @@ #include "system.h" #include "button.h" #include "adc.h" +#include "backlight.h" void button_init_device(void) { /* setup button gpio as input */ GPIO_PCCON &= ~(POWEROFF_BUTTON); + GPIO_PACON &= ~(1); + + /* setup button gpio as pulldown */ + SCU_GPIOUPCON |= (1<<17) | + 1 ; +} + +bool button_hold() { + return (GPIO_PADR & 1); } int button_read_device(void) { int adc_val = adc_read(ADC_BUTTONS); int gpio_btn = GPIO_PCDR & BUTTON_POWER; + static bool hold_button = false; + bool hold_button_old; + + hold_button_old = hold_button; + hold_button = button_hold(); + +#ifndef BOOTLOADER + if (hold_button != hold_button_old) { + backlight_hold_changed(hold_button); + } +#endif + + if (hold_button) { + return 0; + } if (adc_val < 380) { /* 0 - 379 */ 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 @@ #ifndef _BUTTON_TARGET_H_ #define _BUTTON_TARGET_H_ +#define HAS_BUTTON_HOLD + #define BUTTON_UP 0x00000001 #define BUTTON_POWER 0x00000002 #define BUTTON_DOWN 0x00000004 -- cgit v1.2.3