diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c index 2ed2a68ef8..5e40425d30 100644 --- a/apps/recorder/radio.c +++ b/apps/recorder/radio.c @@ -78,7 +78,7 @@ #define FM_PRESET_ADD BUTTON_F1 #define FM_PRESET_ACTION BUTTON_F3 -#elif CONFIG_KEYPAD == IRIVER_H100_PAD +#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) /* pause/play - short PLAY */ #define FM_PLAY_PRE BUTTON_ON #define FM_RC_PLAY_PRE BUTTON_RC_ON @@ -1075,7 +1075,7 @@ int handle_radio_presets_cb(int key, int m) key = BUTTON_NONE; break; #endif -#if CONFIG_KEYPAD != IRIVER_H100_PAD +#if (CONFIG_KEYPAD != IRIVER_H100_PAD) && (CONFIG_KEYPAD != IRIVER_H300_PAD) #ifdef FM_PRESET case FM_PRESET: menu_draw(m); @@ -1285,7 +1285,7 @@ int radio_menu_cb(int key, int m) (void)m; switch(key) { -#if CONFIG_KEYPAD != IRIVER_H100_PAD +#if (CONFIG_KEYPAD != IRIVER_H100_PAD) && (CONFIG_KEYPAD != IRIVER_H300_PAD) #ifdef MENU_ENTER2 case MENU_ENTER2: #endif @@ -1294,7 +1294,7 @@ int radio_menu_cb(int key, int m) key = BUTTON_NONE; /* eat the downpress, next menu reacts on release */ break; -#if CONFIG_KEYPAD != IRIVER_H100_PAD +#if (CONFIG_KEYPAD != IRIVER_H100_PAD) && (CONFIG_KEYPAD != IRIVER_H300_PAD) #ifdef MENU_ENTER2 case MENU_ENTER2 | BUTTON_REL: #endif diff --git a/docs/CREDITS b/docs/CREDITS index a5a1426383..52fead8dff 100644 --- a/docs/CREDITS +++ b/docs/CREDITS @@ -149,3 +149,4 @@ Toshihiko Itoh David J. Song Jeong Taek In Anders Kagerin +Peter D'Hoye diff --git a/firmware/drivers/fmradio_i2c.c b/firmware/drivers/fmradio_i2c.c index 4e491093f0..2475084696 100644 --- a/firmware/drivers/fmradio_i2c.c +++ b/firmware/drivers/fmradio_i2c.c @@ -30,18 +30,38 @@ /* cute little functions, atomic read-modify-write */ /* SDA is GPIO1,23 */ -#define SDA_LO and_l(~0x00800000, &GPIO1_OUT) // and_b(~0x10, &PBDRL) -#define SDA_HI or_l( 0x00800000, &GPIO1_OUT) // or_b( 0x10, &PBDRL) -#define SDA_INPUT and_l(~0x00800000, &GPIO1_ENABLE) // and_b(~0x10, &PBIORL) -#define SDA_OUTPUT or_l( 0x00800000, &GPIO1_ENABLE) // or_b( 0x10, &PBIORL) -#define SDA ( 0x00800000 & GPIO1_READ) // (PBDR & 0x0010) +#ifdef IRIVER_H300_SERIES -/* SCL is GPIO, 3 */ -#define SCL_INPUT and_l(~0x00000008, &GPIO_ENABLE) // and_b(~0x02, &PBIORL) -#define SCL_OUTPUT or_l( 0x00000008, &GPIO_ENABLE) // or_b( 0x02, &PBIORL) -#define SCL_LO and_l(~0x00000008, &GPIO_OUT) // and_b(~0x02, &PBDRL) -#define SCL_HI or_l( 0x00000008, &GPIO_OUT) // or_b( 0x02, &PBDRL) -#define SCL ( 0x00000008 & GPIO_READ) // (PBDR & 0x0002) +/* SDA is GPIO57 */ +#define SDA_LO and_l(~0x02000000, &GPIO1_OUT) +#define SDA_HI or_l( 0x02000000, &GPIO1_OUT) +#define SDA_INPUT and_l(~0x02000000, &GPIO1_ENABLE) +#define SDA_OUTPUT or_l( 0x02000000, &GPIO1_ENABLE) +#define SDA ( 0x02000000 & GPIO1_READ) + +/* SCL is GPIO56 */ +#define SCL_INPUT and_l(~0x01000000, &GPIO1_ENABLE) +#define SCL_OUTPUT or_l( 0x01000000, &GPIO1_ENABLE) +#define SCL_LO and_l(~0x01000000, &GPIO1_OUT) +#define SCL_HI or_l( 0x01000000, &GPIO1_OUT) +#define SCL ( 0x01000000 & GPIO1_READ) + +#else + +/* SDA is GPIO55 */ +#define SDA_LO and_l(~0x00800000, &GPIO1_OUT) +#define SDA_HI or_l( 0x00800000, &GPIO1_OUT) +#define SDA_INPUT and_l(~0x00800000, &GPIO1_ENABLE) +#define SDA_OUTPUT or_l( 0x00800000, &GPIO1_ENABLE) +#define SDA ( 0x00800000 & GPIO1_READ) + +/* SCL is GPIO3 */ +#define SCL_INPUT and_l(~0x00000008, &GPIO_ENABLE) +#define SCL_OUTPUT or_l( 0x00000008, &GPIO_ENABLE) +#define SCL_LO and_l(~0x00000008, &GPIO_OUT) +#define SCL_HI or_l( 0x00000008, &GPIO_OUT) +#define SCL ( 0x00000008 & GPIO_READ) +#endif /* delay loop to achieve 400kHz at 120MHz CPU frequency */ #define DELAY do { int _x; for(_x=0;_x<22;_x++);} while(0) @@ -84,8 +104,8 @@ static void fmradio_i2c_ack(void) SCL_INPUT; /* Set the clock to input */ while(!SCL) /* and wait for the slave to release it */ { - SCL_OUTPUT; /* Set the clock to output */ SCL_HI; + SCL_OUTPUT; /* Set the clock to output */ SCL_INPUT; /* Set the clock to input */ DELAY; } @@ -111,8 +131,8 @@ static int fmradio_i2c_getack(void) SCL_INPUT; /* Set the clock to input */ while(!SCL) /* and wait for the slave to release it */ { - SCL_OUTPUT; /* Set the clock to output */ SCL_HI; + SCL_OUTPUT; /* Set the clock to output */ SCL_INPUT; /* Set the clock to input */ DELAY; } @@ -160,10 +180,12 @@ static unsigned char fmradio_i2c_inb(void) /* clock in each bit, MSB first */ for ( i=0x80; i; i>>=1 ) { SDA_INPUT; /* And set to input */ - SCL_HI; + DELAY; DELAY; if ( SDA ) byte |= i; + SCL_HI; + DELAY; SCL_LO; DELAY; SDA_OUTPUT; diff --git a/firmware/drivers/i2c-coldfire.c b/firmware/drivers/i2c-coldfire.c index 0c83c1cb1a..ffdc4f29de 100644 --- a/firmware/drivers/i2c-coldfire.c +++ b/firmware/drivers/i2c-coldfire.c @@ -46,7 +46,14 @@ void i2c_init(void) or_l(0x00000008, &GPIO_ENABLE); or_l(0x00800000, &GPIO1_FUNCTION); or_l(0x00000008, &GPIO_FUNCTION); +#elif defined(IRIVER_H300_SERIES) + /* The FM chip has no pullup for SCL, so we have to bit-bang the + I2C for that one. */ + or_l(0x03000000, &GPIO1_OUT); + or_l(0x03000000, &GPIO1_ENABLE); + or_l(0x03000000, &GPIO1_FUNCTION); #endif + /* I2C Clock divisor = 576 => 119.952 MHz / 2 / 576 = 104.125 kHz */ MFDR = 0x14; diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h index 5524a55dc0..3f7c7d391e 100644 --- a/firmware/export/config-h300.h +++ b/firmware/export/config-h300.h @@ -48,6 +48,9 @@ /* The number of bytes reserved for loadable plugins */ #define PLUGIN_BUFFER_SIZE 0xC0000 +#define CONFIG_TUNER TEA5767 +#define CONFIG_TUNER_XTAL 32768 + #define HAVE_UDA1380 #ifndef SIMULATOR diff --git a/firmware/pcm_record.c b/firmware/pcm_record.c index d26a4d303a..af58df36d0 100644 --- a/firmware/pcm_record.c +++ b/firmware/pcm_record.c @@ -905,6 +905,15 @@ static void pcmrec_thread(void) /* Select VINL & VINR source: 0=Line-in, 1=FM Radio */ void pcm_rec_mux(int source) { +#ifdef IRIVER_H300_SERIES + if(source == 0) + and_l(~0x40000000, &GPIO_OUT); /* Line In */ + else + or_l(0x40000000, &GPIO_OUT); /* FM radio */ + + or_l(0x40000000, &GPIO_ENABLE); + or_l(0x40000000, &GPIO_FUNCTION); +#else if(source == 0) and_l(~0x00800000, &GPIO_OUT); /* Line In */ else @@ -912,4 +921,5 @@ void pcm_rec_mux(int source) or_l(0x00800000, &GPIO_ENABLE); or_l(0x00800000, &GPIO_FUNCTION); +#endif }