diff options
Diffstat (limited to 'firmware/target/arm/iriver/h10/button-h10.c')
-rw-r--r-- | firmware/target/arm/iriver/h10/button-h10.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/firmware/target/arm/iriver/h10/button-h10.c b/firmware/target/arm/iriver/h10/button-h10.c index 6710f39281..4fd7d3df38 100644 --- a/firmware/target/arm/iriver/h10/button-h10.c +++ b/firmware/target/arm/iriver/h10/button-h10.c | |||
@@ -36,10 +36,10 @@ void button_init_device(void) | |||
36 | { | 36 | { |
37 | /* Enable REW, FF, Play, Left, Right, Hold buttons */ | 37 | /* Enable REW, FF, Play, Left, Right, Hold buttons */ |
38 | GPIO_SET_BITWISE(GPIOA_ENABLE, 0xfc); | 38 | GPIO_SET_BITWISE(GPIOA_ENABLE, 0xfc); |
39 | 39 | ||
40 | /* Enable POWER button */ | 40 | /* Enable POWER button */ |
41 | GPIO_SET_BITWISE(GPIOB_ENABLE, 0x01); | 41 | GPIO_SET_BITWISE(GPIOB_ENABLE, 0x01); |
42 | 42 | ||
43 | /* We need to output to pin 6 of GPIOD when reading the scroll pad value */ | 43 | /* We need to output to pin 6 of GPIOD when reading the scroll pad value */ |
44 | GPIO_SET_BITWISE(GPIOD_ENABLE, 0x40); | 44 | GPIO_SET_BITWISE(GPIOD_ENABLE, 0x40); |
45 | GPIO_SET_BITWISE(GPIOD_OUTPUT_EN, 0x40); | 45 | GPIO_SET_BITWISE(GPIOD_OUTPUT_EN, 0x40); |
@@ -64,13 +64,18 @@ int button_read_device(void) | |||
64 | int btn = BUTTON_NONE; | 64 | int btn = BUTTON_NONE; |
65 | int data; | 65 | int data; |
66 | unsigned char state; | 66 | unsigned char state; |
67 | |||
67 | static bool hold_button = false; | 68 | static bool hold_button = false; |
68 | static bool remote_hold_button = false; | 69 | static bool remote_hold_button = false; |
70 | #ifndef BOOTLOADER | ||
69 | bool hold_button_old; | 71 | bool hold_button_old; |
70 | bool remote_hold_button_old; | 72 | bool remote_hold_button_old; |
73 | #endif | ||
71 | 74 | ||
72 | /* Hold */ | 75 | /* Hold */ |
76 | #ifndef BOOTLOADER | ||
73 | hold_button_old = hold_button; | 77 | hold_button_old = hold_button; |
78 | #endif | ||
74 | hold_button = button_hold(); | 79 | hold_button = button_hold(); |
75 | 80 | ||
76 | #ifndef BOOTLOADER | 81 | #ifndef BOOTLOADER |
@@ -91,10 +96,10 @@ int button_read_device(void) | |||
91 | if ((state & 0x20) == 0) btn |= BUTTON_REW; | 96 | if ((state & 0x20) == 0) btn |= BUTTON_REW; |
92 | if ((state & 0x40) == 0) btn |= BUTTON_RIGHT; | 97 | if ((state & 0x40) == 0) btn |= BUTTON_RIGHT; |
93 | if ((state & 0x80) == 0) btn |= BUTTON_LEFT; | 98 | if ((state & 0x80) == 0) btn |= BUTTON_LEFT; |
94 | 99 | ||
95 | /* Read power button */ | 100 | /* Read power button */ |
96 | if (GPIOB_INPUT_VAL & 0x1) btn |= BUTTON_POWER; | 101 | if (GPIOB_INPUT_VAL & 0x1) btn |= BUTTON_POWER; |
97 | 102 | ||
98 | /* Read scroller */ | 103 | /* Read scroller */ |
99 | if ( GPIOD_INPUT_VAL & 0x20 ) | 104 | if ( GPIOD_INPUT_VAL & 0x20 ) |
100 | { | 105 | { |
@@ -102,7 +107,7 @@ int button_read_device(void) | |||
102 | udelay(250); | 107 | udelay(250); |
103 | data = adc_scan(ADC_SCROLLPAD); | 108 | data = adc_scan(ADC_SCROLLPAD); |
104 | GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL, 0x40); | 109 | GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL, 0x40); |
105 | 110 | ||
106 | if(data < 0x224) | 111 | if(data < 0x224) |
107 | { | 112 | { |
108 | btn |= BUTTON_SCROLL_DOWN; | 113 | btn |= BUTTON_SCROLL_DOWN; |
@@ -111,9 +116,11 @@ int button_read_device(void) | |||
111 | } | 116 | } |
112 | } | 117 | } |
113 | } | 118 | } |
114 | 119 | ||
120 | #ifndef BOOTLOADER | ||
115 | /* remote buttons */ | 121 | /* remote buttons */ |
116 | remote_hold_button_old = remote_hold_button; | 122 | remote_hold_button_old = remote_hold_button; |
123 | #endif | ||
117 | 124 | ||
118 | data = adc_scan(ADC_REMOTE); | 125 | data = adc_scan(ADC_REMOTE); |
119 | remote_hold_button = data < 0x2B; | 126 | remote_hold_button = data < 0x2B; |
@@ -143,6 +150,6 @@ int button_read_device(void) | |||
143 | /* remote play button should be dead if hold */ | 150 | /* remote play button should be dead if hold */ |
144 | if (!remote_hold_button && !(GPIOA_INPUT_VAL & 0x1)) | 151 | if (!remote_hold_button && !(GPIOA_INPUT_VAL & 0x1)) |
145 | btn |= BUTTON_RC_PLAY; | 152 | btn |= BUTTON_RC_PLAY; |
146 | 153 | ||
147 | return btn; | 154 | return btn; |
148 | } | 155 | } |