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:
parent
ed69390542
commit
d7b4645f5c
5 changed files with 69 additions and 4 deletions
23
firmware/config-fmrecorder.h
Normal file
23
firmware/config-fmrecorder.h
Normal 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
|
|
@ -23,8 +23,12 @@
|
|||
|
||||
#define ADC_BATTERY 0 /* Battery voltage always reads 0x3FF due to
|
||||
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
|
||||
about 0x1c0 when charging, else 0x3FF */
|
||||
#endif
|
||||
#define ADC_USB_POWER 2 /* USB, reads 0x3FF when USB is inserted */
|
||||
|
||||
#define ADC_BUTTON_ROW1 4 /* Used for scanning the keys, different
|
||||
|
|
|
@ -191,10 +191,19 @@ int button_get_w_tmo(int ticks)
|
|||
* DOWN, PLAY, LEFT, and RIGHT are likewise connected to AN5. */
|
||||
|
||||
/* 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 LEVEL2 500
|
||||
#define LEVEL3 700
|
||||
#define LEVEL4 900
|
||||
#endif
|
||||
|
||||
/*
|
||||
*Initialize buttons
|
||||
|
@ -219,11 +228,22 @@ static int button_read(void)
|
|||
int btn = BUTTON_NONE;
|
||||
|
||||
/* 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)
|
||||
btn |= BUTTON_ON;
|
||||
else if ((data & PBDR_BTN_OFF) == 0)
|
||||
btn |= BUTTON_OFF;
|
||||
#endif
|
||||
|
||||
/* Check F1-3 and UP */
|
||||
data = adc_read(ADC_BUTTON_ROW1);
|
||||
|
@ -245,12 +265,22 @@ static int button_read(void)
|
|||
data = adc_read(ADC_BUTTON_ROW2);
|
||||
if (data >= LEVEL4)
|
||||
btn |= BUTTON_DOWN;
|
||||
else if (data >= LEVEL3)
|
||||
else if (data >= LEVEL3) {
|
||||
#ifdef HAVE_FMADC
|
||||
btn |= BUTTON_RIGHT;
|
||||
#else
|
||||
btn |= BUTTON_PLAY;
|
||||
#endif
|
||||
}
|
||||
else if (data >= LEVEL2)
|
||||
btn |= BUTTON_LEFT;
|
||||
else if (data >= LEVEL1)
|
||||
else if (data >= LEVEL1) {
|
||||
#ifdef HAVE_FMADC
|
||||
btn |= BUTTON_PLAY;
|
||||
#else
|
||||
btn |= BUTTON_RIGHT;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return btn;
|
||||
|
|
|
@ -31,8 +31,12 @@ bool charger_enabled = 0;
|
|||
|
||||
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;
|
||||
#endif
|
||||
#else
|
||||
return (PADR & 1) == 0;
|
||||
#endif
|
||||
|
|
|
@ -217,8 +217,12 @@ static void usb_tick(void)
|
|||
{
|
||||
#ifdef ARCHOS_RECORDER
|
||||
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
|
||||
current_status = (PADR & 0x8000)?false:true;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Only report when the status has changed */
|
||||
|
|
Loading…
Reference in a new issue