summaryrefslogtreecommitdiff
path: root/firmware/drivers/button.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-06-30 20:24:57 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-06-30 20:24:57 +0000
commitd1c88e728ba324fa38a59656bfce4db2cf6d8db7 (patch)
treea12d840cd1bfa9462a97134df235c1fbd7d0d6ac /firmware/drivers/button.c
parent3189353946ad221a9a0254ca6a7ff10fde172b09 (diff)
Now uses adc_read()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1276 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/button.c')
-rw-r--r--firmware/drivers/button.c18
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 @@
#include "button.h"
#include "kernel.h"
#include "backlight.h"
+#include "adc.h"
struct event_queue button_queue;
@@ -118,7 +119,7 @@ int button_get(bool block)
*
* DOWN, PLAY, LEFT, and RIGHT are likewise connected to AN5. */
-/* Button voltage levels on AN4 and AN5 */
+/* Button analog voltage levels */
#define LEVEL1 50
#define LEVEL2 125
#define LEVEL3 175
@@ -134,13 +135,6 @@ void button_init()
PBCR1 &= 0xfffc; /* PB8MD = 00 */
PBCR2 &= 0xfcff; /* PB4MD = 00 */
PBIOR &= ~(PBDR_BTN_ON|PBDR_BTN_OFF); /* Inputs */
-
- /* Set A/D to scan AN4 and AN5.
- * This needs to be changed to scan other analog pins
- * for battery level, etc. */
- ADCSR = 0;
- ADCR = 0;
- ADCSR = ADCSR_ADST | ADCSR_SCAN | 0x5;
#endif
queue_init(&button_queue);
tick_add_task(button_tick);
@@ -158,8 +152,8 @@ static int button_read(void)
else if ((data & PBDR_BTN_OFF) == 0)
return BUTTON_OFF;
- /* Check AN4 pin for F1-3 and UP */
- data = ADDRAH;
+ /* Check F1-3 and UP */
+ data = adc_read(ADC_BUTTON_ROW1);
if (data >= LEVEL4)
return BUTTON_F3;
else if (data >= LEVEL3)
@@ -169,8 +163,8 @@ static int button_read(void)
else if (data >= LEVEL1)
return BUTTON_F1;
- /* Check AN5 pin for DOWN, PLAY, LEFT, RIGHT */
- data = ADDRBH;
+ /* Check DOWN, PLAY, LEFT, RIGHT */
+ data = adc_read(ADC_BUTTON_ROW2);
if (data >= LEVEL4)
return BUTTON_DOWN;
else if (data >= LEVEL3)