From d7b4645f5c7274660c9a020f172ac54f546686b5 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 16 Jan 2003 15:11:29 +0000 Subject: 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 --- firmware/config-fmrecorder.h | 23 +++++++++++++++++++++++ firmware/drivers/adc.h | 4 ++++ firmware/drivers/button.c | 36 +++++++++++++++++++++++++++++++++--- firmware/drivers/power.c | 6 +++++- firmware/usb.c | 4 ++++ 5 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 firmware/config-fmrecorder.h diff --git a/firmware/config-fmrecorder.h b/firmware/config-fmrecorder.h new file mode 100644 index 0000000000..ed3454ff7e --- /dev/null +++ b/firmware/config-fmrecorder.h @@ -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 diff --git a/firmware/drivers/adc.h b/firmware/drivers/adc.h index 0c05f4d0f8..9c90cb08a7 100644 --- a/firmware/drivers/adc.h +++ b/firmware/drivers/adc.h @@ -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 diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index ea3ffadffd..ebf606ac25 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -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; diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c index b61090ff26..bb0ec80942 100644 --- a/firmware/drivers/power.c +++ b/firmware/drivers/power.c @@ -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 diff --git a/firmware/usb.c b/firmware/usb.c index 64474c7b66..fcc06c2f6e 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -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 */ -- cgit v1.2.3