diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-06-30 20:24:57 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-06-30 20:24:57 +0000 |
commit | d1c88e728ba324fa38a59656bfce4db2cf6d8db7 (patch) | |
tree | a12d840cd1bfa9462a97134df235c1fbd7d0d6ac /firmware/drivers | |
parent | 3189353946ad221a9a0254ca6a7ff10fde172b09 (diff) | |
download | rockbox-d1c88e728ba324fa38a59656bfce4db2cf6d8db7.tar.gz rockbox-d1c88e728ba324fa38a59656bfce4db2cf6d8db7.zip |
Now uses adc_read()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1276 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/button.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 327654e3e1..9805c1858a 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "button.h" | 27 | #include "button.h" |
28 | #include "kernel.h" | 28 | #include "kernel.h" |
29 | #include "backlight.h" | 29 | #include "backlight.h" |
30 | #include "adc.h" | ||
30 | 31 | ||
31 | struct event_queue button_queue; | 32 | struct event_queue button_queue; |
32 | 33 | ||
@@ -118,7 +119,7 @@ int button_get(bool block) | |||
118 | * | 119 | * |
119 | * DOWN, PLAY, LEFT, and RIGHT are likewise connected to AN5. */ | 120 | * DOWN, PLAY, LEFT, and RIGHT are likewise connected to AN5. */ |
120 | 121 | ||
121 | /* Button voltage levels on AN4 and AN5 */ | 122 | /* Button analog voltage levels */ |
122 | #define LEVEL1 50 | 123 | #define LEVEL1 50 |
123 | #define LEVEL2 125 | 124 | #define LEVEL2 125 |
124 | #define LEVEL3 175 | 125 | #define LEVEL3 175 |
@@ -134,13 +135,6 @@ void button_init() | |||
134 | PBCR1 &= 0xfffc; /* PB8MD = 00 */ | 135 | PBCR1 &= 0xfffc; /* PB8MD = 00 */ |
135 | PBCR2 &= 0xfcff; /* PB4MD = 00 */ | 136 | PBCR2 &= 0xfcff; /* PB4MD = 00 */ |
136 | PBIOR &= ~(PBDR_BTN_ON|PBDR_BTN_OFF); /* Inputs */ | 137 | PBIOR &= ~(PBDR_BTN_ON|PBDR_BTN_OFF); /* Inputs */ |
137 | |||
138 | /* Set A/D to scan AN4 and AN5. | ||
139 | * This needs to be changed to scan other analog pins | ||
140 | * for battery level, etc. */ | ||
141 | ADCSR = 0; | ||
142 | ADCR = 0; | ||
143 | ADCSR = ADCSR_ADST | ADCSR_SCAN | 0x5; | ||
144 | #endif | 138 | #endif |
145 | queue_init(&button_queue); | 139 | queue_init(&button_queue); |
146 | tick_add_task(button_tick); | 140 | tick_add_task(button_tick); |
@@ -158,8 +152,8 @@ static int button_read(void) | |||
158 | else if ((data & PBDR_BTN_OFF) == 0) | 152 | else if ((data & PBDR_BTN_OFF) == 0) |
159 | return BUTTON_OFF; | 153 | return BUTTON_OFF; |
160 | 154 | ||
161 | /* Check AN4 pin for F1-3 and UP */ | 155 | /* Check F1-3 and UP */ |
162 | data = ADDRAH; | 156 | data = adc_read(ADC_BUTTON_ROW1); |
163 | if (data >= LEVEL4) | 157 | if (data >= LEVEL4) |
164 | return BUTTON_F3; | 158 | return BUTTON_F3; |
165 | else if (data >= LEVEL3) | 159 | else if (data >= LEVEL3) |
@@ -169,8 +163,8 @@ static int button_read(void) | |||
169 | else if (data >= LEVEL1) | 163 | else if (data >= LEVEL1) |
170 | return BUTTON_F1; | 164 | return BUTTON_F1; |
171 | 165 | ||
172 | /* Check AN5 pin for DOWN, PLAY, LEFT, RIGHT */ | 166 | /* Check DOWN, PLAY, LEFT, RIGHT */ |
173 | data = ADDRBH; | 167 | data = adc_read(ADC_BUTTON_ROW2); |
174 | if (data >= LEVEL4) | 168 | if (data >= LEVEL4) |
175 | return BUTTON_DOWN; | 169 | return BUTTON_DOWN; |
176 | else if (data >= LEVEL3) | 170 | else if (data >= LEVEL3) |