1
0
Fork 0
forked from len0rd/rockbox

Ludovic Lange's initial code for FM Recorder, edited and adjusted by me.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3110 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2003-01-16 15:11:29 +00:00
parent ed69390542
commit d7b4645f5c
5 changed files with 69 additions and 4 deletions

View file

@ -0,0 +1,23 @@
/* define this if you have recording possibility */
#define HAVE_RECORDING 1
/* define this if you have a bitmap LCD display */
#define HAVE_LCD_BITMAP 1
/* define this if you have a Recorder style 10-key keyboard */
#define HAVE_RECORDER_KEYPAD 1
/* define this if you have a real-time clock */
#define HAVE_RTC 1
/* Define this if you have a MAS3587F */
#define HAVE_MAS3587F
/* Define this if you have charging control */
#define HAVE_CHARGE_CTRL
/* Define this if you have ATA power-off control */
#define HAVE_ATA_POWER_OFF
/* Define this if you have a FM Recorder key system */
#define HAVE_FMADC 1

View file

@ -23,8 +23,12 @@
#define ADC_BATTERY 0 /* Battery voltage always reads 0x3FF due to #define ADC_BATTERY 0 /* Battery voltage always reads 0x3FF due to
silly scaling */ silly scaling */
#ifdef HAVE_FMADC
#define ADC_CHARGE_REGULATOR 0 /* Uh, we read the battery voltage? */
#else
#define ADC_CHARGE_REGULATOR 1 /* Regulator reference voltage, should read #define ADC_CHARGE_REGULATOR 1 /* Regulator reference voltage, should read
about 0x1c0 when charging, else 0x3FF */ about 0x1c0 when charging, else 0x3FF */
#endif
#define ADC_USB_POWER 2 /* USB, reads 0x3FF when USB is inserted */ #define ADC_USB_POWER 2 /* USB, reads 0x3FF when USB is inserted */
#define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different #define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different

View file

@ -191,10 +191,19 @@ int button_get_w_tmo(int ticks)
* DOWN, PLAY, LEFT, and RIGHT are likewise connected to AN5. */ * DOWN, PLAY, LEFT, and RIGHT are likewise connected to AN5. */
/* Button analog voltage levels */ /* Button analog voltage levels */
#ifdef HAVE_FMADC
/* FM Recorder super-special levels */
#define LEVEL1 150
#define LEVEL2 385
#define LEVEL3 545
#define LEVEL4 700
#else
/* plain bog standard Recorder levels */
#define LEVEL1 250 #define LEVEL1 250
#define LEVEL2 500 #define LEVEL2 500
#define LEVEL3 700 #define LEVEL3 700
#define LEVEL4 900 #define LEVEL4 900
#endif
/* /*
*Initialize buttons *Initialize buttons
@ -219,11 +228,22 @@ static int button_read(void)
int btn = BUTTON_NONE; int btn = BUTTON_NONE;
/* Check port B pins for ON and OFF */ /* Check port B pins for ON and OFF */
int data = PBDR; int data;
#ifdef HAVE_FMADC
/* TODO: use proper defines here, and not the numerics in the
function argument */
if ( adc_read(3) < 512 )
btn |= BUTTON_ON;
if ( adc_read(2) > 512 )
btn |= BUTTON_OFF;
#else
data = PBDR;
if ((data & PBDR_BTN_ON) == 0) if ((data & PBDR_BTN_ON) == 0)
btn |= BUTTON_ON; btn |= BUTTON_ON;
else if ((data & PBDR_BTN_OFF) == 0) else if ((data & PBDR_BTN_OFF) == 0)
btn |= BUTTON_OFF; btn |= BUTTON_OFF;
#endif
/* Check F1-3 and UP */ /* Check F1-3 and UP */
data = adc_read(ADC_BUTTON_ROW1); data = adc_read(ADC_BUTTON_ROW1);
@ -245,12 +265,22 @@ static int button_read(void)
data = adc_read(ADC_BUTTON_ROW2); data = adc_read(ADC_BUTTON_ROW2);
if (data >= LEVEL4) if (data >= LEVEL4)
btn |= BUTTON_DOWN; btn |= BUTTON_DOWN;
else if (data >= LEVEL3) else if (data >= LEVEL3) {
#ifdef HAVE_FMADC
btn |= BUTTON_RIGHT;
#else
btn |= BUTTON_PLAY; btn |= BUTTON_PLAY;
#endif
}
else if (data >= LEVEL2) else if (data >= LEVEL2)
btn |= BUTTON_LEFT; btn |= BUTTON_LEFT;
else if (data >= LEVEL1) else if (data >= LEVEL1) {
#ifdef HAVE_FMADC
btn |= BUTTON_PLAY;
#else
btn |= BUTTON_RIGHT; btn |= BUTTON_RIGHT;
#endif
}
} }
return btn; return btn;

View file

@ -31,8 +31,12 @@ bool charger_enabled = 0;
bool charger_inserted(void) bool charger_inserted(void)
{ {
#ifdef ARCHOS_RECORDER #ifdef HAVE_CHARGE_CTRL
#ifdef HAVE_FMADC
return adc_read(ADC_CHARGE_REGULATOR) < 0x1FF;
#else
return adc_read(ADC_EXT_POWER) > 0x100; return adc_read(ADC_EXT_POWER) > 0x100;
#endif
#else #else
return (PADR & 1) == 0; return (PADR & 1) == 0;
#endif #endif

View file

@ -217,8 +217,12 @@ static void usb_tick(void)
{ {
#ifdef ARCHOS_RECORDER #ifdef ARCHOS_RECORDER
current_status = (adc_read(ADC_USB_POWER) > 500)?true:false; current_status = (adc_read(ADC_USB_POWER) > 500)?true:false;
#else
#ifdef ARCHOS_FMRECORDER
current_status = (adc_read(ADC_USB_POWER) < 512)?true:false;
#else #else
current_status = (PADR & 0x8000)?false:true; current_status = (PADR & 0x8000)?false:true;
#endif
#endif #endif
/* Only report when the status has changed */ /* Only report when the status has changed */