From d83e929f3fc369a5981e1e40e1c5307169a46cfc Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Thu, 12 Jan 2006 00:35:50 +0000 Subject: Work-in-progress iriver iFP-7xx port by Tomasz Malesinski git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8342 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/adc.c | 34 ++++++++++++++++++++++++++++ firmware/drivers/button.c | 50 ++++++++++++++++++++++++++++++++++++++++- firmware/drivers/lcd-recorder.c | 31 +++++++++++++++++++++++++ firmware/drivers/power.c | 5 +++++ firmware/drivers/serial.c | 3 ++- 5 files changed, 121 insertions(+), 2 deletions(-) (limited to 'firmware/drivers') diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c index c9ae2daca8..ad10017d85 100644 --- a/firmware/drivers/adc.c +++ b/firmware/drivers/adc.c @@ -294,4 +294,38 @@ void adc_init(void) } +#elif CONFIG_CPU == PNX0101 + +static unsigned short adcdata[NUM_ADC_CHANNELS]; + +unsigned short adc_read(int channel) +{ + return adcdata[channel]; +} + +static void adc_tick(void) +{ + if (ADCST & 0x10) { + adcdata[0] = ADCCH0 & 0x3ff; + adcdata[1] = ADCCH1 & 0x3ff; + adcdata[2] = ADCCH2 & 0x3ff; + adcdata[3] = ADCCH3 & 0x3ff; + adcdata[4] = ADCCH4 & 0x3ff; + ADCST = 0xa; + } +} + +void adc_init(void) +{ + ADCR24 = 0xaaaaa; + ADCR28 = 0; + ADCST = 2; + ADCST = 0xa; + + while (!(ADCST & 0x10)); + adc_tick(); + + tick_add_task(adc_tick); +} + #endif diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 544cfec32e..0c17fce4c6 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -61,7 +61,7 @@ static bool flipped; /* buttons can be flipped to match the LCD flip */ #define REPEAT_INTERVAL_FINISH 5 /* the power-off button and number of repeated keys before shutting off */ -#if CONFIG_KEYPAD == IPOD_4G_PAD +#if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD) #define POWEROFF_BUTTON BUTTON_PLAY #define POWEROFF_COUNT 40 #else @@ -731,6 +731,47 @@ static int button_read(void) if (!remote_hold_button && ((data & 0x40) == 0)) btn |= BUTTON_RC_ON; +#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD + + static bool hold_button = false; + + /* light handling */ + if (hold_button && !button_hold()) + { + backlight_on(); + } + hold_button = button_hold(); + + /* normal buttons */ + if (!button_hold()) + { + data = adc_read(ADC_BUTTONS); + + if (data < 0x151) + if (data < 0xc7) + if (data < 0x41) + btn = BUTTON_LEFT; + else + btn = BUTTON_RIGHT; + else + btn = BUTTON_SELECT; + else + if (data < 0x268) + if (data < 0x1d7) + btn = BUTTON_UP; + else + btn = BUTTON_DOWN; + else + if (data < 0x2f9) + btn = BUTTON_EQ; + else + if (data < 0x35c) + btn = BUTTON_MODE; + } + + if (!button_hold() && (adc_read(ADC_BUTTON_PLAY) < 0x64)) + btn |= BUTTON_PLAY; + #elif CONFIG_KEYPAD == RECORDER_PAD #ifdef HAVE_FMADC @@ -877,6 +918,13 @@ bool remote_button_hold(void) } #endif +#if CONFIG_KEYPAD == IRIVER_IFP7XX_PAD +bool button_hold(void) +{ + return (GPIO5_READ & 4) ? false : true; +} +#endif + int button_status(void) { return lastbtn; diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c index 081a7a5267..523e8a1c09 100644 --- a/firmware/drivers/lcd-recorder.c +++ b/firmware/drivers/lcd-recorder.c @@ -135,6 +135,24 @@ void lcd_write_data( const unsigned char* data, int count ) { P2 |= 0x20; } } + +#elif CONFIG_CPU == PNX0101 + +void lcd_write_command(int cmd) +{ + while ((LCDSTAT & 3) != 3); + LCDCMD = cmd; +} + +void lcd_write_data( const unsigned char* data, int count ) +{ + int i; + for (i=0; i < count; i++) { + while ((LCDSTAT & 3) != 3); + LCDDATA = data[i]; + } +} + #endif /*** hardware configuration ***/ @@ -145,6 +163,8 @@ int lcd_default_contrast(void) return 30; #elif CONFIG_LCD == LCD_GMINI100 return 31; +#elif CONFIG_LCD == LCD_IFP7XX + return 45; #else return (read_hw_mask() & LCD_CONTRAST_BIAS) ? 31 : 49; #endif @@ -197,7 +217,11 @@ void lcd_set_flip(bool yesno) { lcd_write_command(LCD_SET_SEGMENT_REMAP | 0x01); lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION | 0x08); +#if CONFIG_LCD == LCD_IFP7XX + xoffset = 4; +#else xoffset = 0; +#endif } #endif } @@ -236,6 +260,9 @@ void lcd_init(void) P2CONL |= 0x5a; P2CONL &= 0x5b; P2CONH |= 1; +#elif CONFIG_CPU == PNX0101 + LCDREG10 = 0xf; + LCDREG04 = 0x4084; #else /* Initialize PB0-3 as output pins */ PBCR2 &= 0xff00; /* MD = 00 */ @@ -245,7 +272,11 @@ void lcd_init(void) /* inits like the original firmware */ lcd_write_command(LCD_SOFTWARE_RESET); lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO + 4); +#if CONFIG_LCD == LCD_IFP7XX + lcd_write_command(LCD_SET_LCD_BIAS); +#else lcd_write_command(LCD_SET_1OVER4_BIAS_RATIO + 0); /* force 1/4 bias: 0 */ +#endif lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER + 7); /* power control register: op-amp=1, regulator=1, booster=1 */ lcd_write_command(LCD_SET_DISPLAY_ON); diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c index 141d985ee6..da97233e57 100644 --- a/firmware/drivers/power.c +++ b/firmware/drivers/power.c @@ -182,6 +182,8 @@ void ide_power_enable(bool on) P1 |= 0x08; else P1 &= ~0x08; +#elif CONFIG_CPU == PNX0101 + /* no ide controller */ #else /* SH1 based archos */ bool touched = false; #ifdef NEEDS_ATA_POWER_ON @@ -266,6 +268,9 @@ void power_off(void) /* We don't turn off the ipod, we put it in a deep sleep */ pcf50605_standby_mode(); #endif +#elif CONFIG_CPU == PNX0101 + GPIO1_CLR = 1 << 16; + GPIO2_SET = 1; #elif defined(GMINI_ARCH) P1 &= ~1; P1CON &= ~1; diff --git a/firmware/drivers/serial.c b/firmware/drivers/serial.c index 4c5c5a8172..27061c299b 100644 --- a/firmware/drivers/serial.c +++ b/firmware/drivers/serial.c @@ -27,8 +27,9 @@ #include "lcd.h" #include "serial.h" -#if (CONFIG_CPU != MCF5249) && (CONFIG_CPU != TCC730) && (CONFIG_CPU != PP5020) +#if (CONFIG_CPU != MCF5249) && (CONFIG_CPU != TCC730) && (CONFIG_CPU != PP5020) && (CONFIG_CPU != PNX0101) /* FIX: this doesn't work on iRiver or Gmini or iPod yet */ +/* iFP7xx has no remote */ #ifndef HAVE_MMC /* MMC takes serial port 1, so don't mess with it */ -- cgit v1.2.3