forked from len0rd/rockbox
Now uses adc_read()
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1276 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3189353946
commit
d1c88e728b
2 changed files with 8 additions and 13 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include "button.h"
|
#include "button.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
|
#include "adc.h"
|
||||||
|
|
||||||
struct event_queue button_queue;
|
struct event_queue button_queue;
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ int button_get(bool block)
|
||||||
*
|
*
|
||||||
* DOWN, PLAY, LEFT, and RIGHT are likewise connected to AN5. */
|
* 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 LEVEL1 50
|
||||||
#define LEVEL2 125
|
#define LEVEL2 125
|
||||||
#define LEVEL3 175
|
#define LEVEL3 175
|
||||||
|
@ -134,13 +135,6 @@ void button_init()
|
||||||
PBCR1 &= 0xfffc; /* PB8MD = 00 */
|
PBCR1 &= 0xfffc; /* PB8MD = 00 */
|
||||||
PBCR2 &= 0xfcff; /* PB4MD = 00 */
|
PBCR2 &= 0xfcff; /* PB4MD = 00 */
|
||||||
PBIOR &= ~(PBDR_BTN_ON|PBDR_BTN_OFF); /* Inputs */
|
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
|
#endif
|
||||||
queue_init(&button_queue);
|
queue_init(&button_queue);
|
||||||
tick_add_task(button_tick);
|
tick_add_task(button_tick);
|
||||||
|
@ -158,8 +152,8 @@ static int button_read(void)
|
||||||
else if ((data & PBDR_BTN_OFF) == 0)
|
else if ((data & PBDR_BTN_OFF) == 0)
|
||||||
return BUTTON_OFF;
|
return BUTTON_OFF;
|
||||||
|
|
||||||
/* Check AN4 pin for F1-3 and UP */
|
/* Check F1-3 and UP */
|
||||||
data = ADDRAH;
|
data = adc_read(ADC_BUTTON_ROW1);
|
||||||
if (data >= LEVEL4)
|
if (data >= LEVEL4)
|
||||||
return BUTTON_F3;
|
return BUTTON_F3;
|
||||||
else if (data >= LEVEL3)
|
else if (data >= LEVEL3)
|
||||||
|
@ -169,8 +163,8 @@ static int button_read(void)
|
||||||
else if (data >= LEVEL1)
|
else if (data >= LEVEL1)
|
||||||
return BUTTON_F1;
|
return BUTTON_F1;
|
||||||
|
|
||||||
/* Check AN5 pin for DOWN, PLAY, LEFT, RIGHT */
|
/* Check DOWN, PLAY, LEFT, RIGHT */
|
||||||
data = ADDRBH;
|
data = adc_read(ADC_BUTTON_ROW2);
|
||||||
if (data >= LEVEL4)
|
if (data >= LEVEL4)
|
||||||
return BUTTON_DOWN;
|
return BUTTON_DOWN;
|
||||||
else if (data >= LEVEL3)
|
else if (data >= LEVEL3)
|
||||||
|
|
|
@ -173,7 +173,8 @@ static void usb_tick(void)
|
||||||
if(usb_monitor_enabled)
|
if(usb_monitor_enabled)
|
||||||
{
|
{
|
||||||
#ifdef ARCHOS_RECORDER
|
#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
|
#else
|
||||||
current_status = (PADR & 0x8000)?false:true;
|
current_status = (PADR & 0x8000)?false:true;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue