From a69e1c4a4425a69a920f7a85c45b1ac6de717a07 Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Wed, 5 May 2010 04:06:44 +0000 Subject: Fuzev2: FM - tested on 2 different models git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25818 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/config/sansafuzev2.h | 4 +-- firmware/target/arm/as3525/fmradio-i2c-as3525.c | 34 ++++++++++++++++++---- .../target/arm/as3525/sansa-fuzev2/button-fuzev2.c | 7 +++++ 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/firmware/export/config/sansafuzev2.h b/firmware/export/config/sansafuzev2.h index 4caab8464a..b920e4153b 100644 --- a/firmware/export/config/sansafuzev2.h +++ b/firmware/export/config/sansafuzev2.h @@ -21,7 +21,7 @@ /* Define bitmask of input sources - recordable bitmask can be defined explicitly if different */ -#define INPUT_SRC_CAPS (SRC_CAP_MIC /*| SRC_CAP_FMRADIO*/) +#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO) /* define this if you have a bitmap LCD display */ #define HAVE_LCD_BITMAP @@ -117,7 +117,7 @@ #define AB_REPEAT_ENABLE 1 /* FM Tuner - suspected to be the SI4702 */ -//#define CONFIG_TUNER SI4700 +#define CONFIG_TUNER SI4700 /* #define HAVE_TUNER_PWR_CTRL */ /* Define this for LCD backlight available */ diff --git a/firmware/target/arm/as3525/fmradio-i2c-as3525.c b/firmware/target/arm/as3525/fmradio-i2c-as3525.c index c86e3f53ab..31d701dc6d 100644 --- a/firmware/target/arm/as3525/fmradio-i2c-as3525.c +++ b/firmware/target/arm/as3525/fmradio-i2c-as3525.c @@ -30,6 +30,7 @@ #include "as3525.h" #include "generic_i2c.h" #include "fmradio_i2c.h" +#include "system.h" #if defined(SANSA_CLIP) || defined(SANSA_C200V2) #define I2C_SCL_GPIO(x) GPIOB_PIN(x) @@ -63,6 +64,14 @@ #define I2C_SCL_PIN 6 #define I2C_SDA_PIN 7 +#elif defined(SANSA_FUZEV2) +#define I2C_SCL_GPIO(x) GPIOB_PIN(x) +#define I2C_SDA_GPIO(x) GPIOA_PIN(x) +#define I2C_SCL_GPIO_DIR GPIOB_DIR +#define I2C_SDA_GPIO_DIR GPIOA_DIR +#define I2C_SCL_PIN 1 +#define I2C_SDA_PIN 0 + #else #error no FM I2C GPIOPIN defines #endif @@ -158,13 +167,28 @@ void fmradio_i2c_init(void) int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) { - return i2c_write_data(fm_i2c_bus, address, -1, buf, count); +#ifdef SANSA_FUZEV2 + int s = disable_irq_save(); + CCU_IO &= ~(1<<12); +#endif + int ret = i2c_write_data(fm_i2c_bus, address, -1, buf, count); +#ifdef SANSA_FUZEV2 + CCU_IO |= 1<<12; + restore_irq(s); +#endif + return ret; } int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count) { - return i2c_read_data(fm_i2c_bus, address, -1, buf, count); +#ifdef SANSA_FUZEV2 + int s = disable_irq_save(); + CCU_IO &= ~(1<<12); +#endif + int ret = i2c_read_data(fm_i2c_bus, address, -1, buf, count); +#ifdef SANSA_FUZEV2 + CCU_IO |= 1<<12; + restore_irq(s); +#endif + return ret; } - - - diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c index d23fb432d6..fcda5226ca 100644 --- a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c +++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c @@ -232,6 +232,10 @@ int button_read_device(void) CCU_IO &= ~(1<<12); + /* B1 is shared with FM i2c */ + bool gpiob_pin0_dir = GPIOB_DIR & (1<<1); + GPIOB_DIR &= ~(1<<1); + GPIOB_PIN(0) = 1<<0; udelay(4); @@ -266,6 +270,9 @@ int button_read_device(void) } } + if(gpiob_pin0_dir) + GPIOB_DIR |= 1<<1; + CCU_IO |= 1<<12; #ifdef HAS_BUTTON_HOLD -- cgit v1.2.3