summaryrefslogtreecommitdiff
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
parent3189353946ad221a9a0254ca6a7ff10fde172b09 (diff)
downloadrockbox-d1c88e728ba324fa38a59656bfce4db2cf6d8db7.zip
rockbox-d1c88e728ba324fa38a59656bfce4db2cf6d8db7.tar.gz
rockbox-d1c88e728ba324fa38a59656bfce4db2cf6d8db7.tar.bz2
rockbox-d1c88e728ba324fa38a59656bfce4db2cf6d8db7.tar.xz
Now uses adc_read()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1276 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/button.c18
-rw-r--r--firmware/usb.c3
2 files changed, 8 insertions, 13 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 327654e..9805c18 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)
diff --git a/firmware/usb.c b/firmware/usb.c
index 3e6f058..268cab6 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -173,7 +173,8 @@ static void usb_tick(void)
if(usb_monitor_enabled)
{
#ifdef ARCHOS_RECORDER
- current_status = (PCDR & 0x04)?true:false;
+ /* If AN2 reads more than about 500, the USB is inserted */
+ current_status = (adc_read(2) > 500);
#else
current_status = (PADR & 0x8000)?false:true;
#endif