diff options
author | Dominik Wenger <domonoky@googlemail.com> | 2008-12-09 17:21:16 +0000 |
---|---|---|
committer | Dominik Wenger <domonoky@googlemail.com> | 2008-12-09 17:21:16 +0000 |
commit | 02184a242edd2e92f5305a29cadd6bc71448875a (patch) | |
tree | 965ab0d62a1df33d70da4d879cb67ccfc1007d72 /firmware | |
parent | 4ae9de5490c06ab06d96d7f5006e77eb69907ed6 (diff) |
make fmradio-i2c code from clip more generic, so it works for m200v4 and hopefully all other as3525 targets.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19370 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 2 | ||||
-rw-r--r-- | firmware/target/arm/as3525/fmradio-i2c-as3525.c (renamed from firmware/target/arm/as3525/sansa-clip/fmradio-i2c-clip.c) | 39 |
2 files changed, 31 insertions, 10 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 3fadec005e..68d10876c8 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -1094,6 +1094,8 @@ target/arm/lcd-ssd1815.c target/arm/as3525/sansa-m200v4/button-m200v4.c #ifndef BOOTLOADER target/arm/as3525/powermgmt-as3525.c +drivers/generic_i2c.c +target/arm/as3525/fmradio-i2c-as3525.c #endif /* !BOOTLOADER */ #endif /* !SIMULATOR */ #endif /* SANSA_M200V4 */ diff --git a/firmware/target/arm/as3525/sansa-clip/fmradio-i2c-clip.c b/firmware/target/arm/as3525/fmradio-i2c-as3525.c index e3444b8acf..18f29dbc57 100644 --- a/firmware/target/arm/as3525/sansa-clip/fmradio-i2c-clip.c +++ b/firmware/target/arm/as3525/fmradio-i2c-as3525.c @@ -31,57 +31,70 @@ #include "generic_i2c.h" #include "fmradio_i2c.h" +#if defined(SANSA_CLIP) +#define I2C_GPIO(x) GPIOB_PIN(x) +#define I2C_GPIO_DIR GPIOB_DIR #define I2C_SCL_PIN 4 #define I2C_SDA_PIN 5 +#elif defined(SANSA_M200V4) +#define I2C_GPIO(x) GPIOD_PIN(x) +#define I2C_GPIO_DIR GPIOD_DIR +#define I2C_SCL_PIN 7 +#define I2C_SDA_PIN 6 + +#elif +#error no FM I2C GPIOPIN defines +#endif + static void fm_scl_hi(void) { - GPIOB_PIN(I2C_SCL_PIN) = 1 << I2C_SCL_PIN; + I2C_GPIO(I2C_SCL_PIN) = 1 << I2C_SCL_PIN; } static void fm_scl_lo(void) { - GPIOB_PIN(I2C_SCL_PIN) = 0; + I2C_GPIO(I2C_SCL_PIN) = 0; } static void fm_sda_hi(void) { - GPIOB_PIN(I2C_SDA_PIN) = 1 << I2C_SDA_PIN; + I2C_GPIO(I2C_SDA_PIN) = 1 << I2C_SDA_PIN; } static void fm_sda_lo(void) { - GPIOB_PIN(I2C_SDA_PIN) = 0; + I2C_GPIO(I2C_SDA_PIN) = 0; } static void fm_sda_input(void) { - GPIOB_DIR &= ~(1 << I2C_SDA_PIN); + I2C_GPIO_DIR &= ~(1 << I2C_SDA_PIN); } static void fm_sda_output(void) { - GPIOB_DIR |= 1 << I2C_SDA_PIN; + I2C_GPIO_DIR |= 1 << I2C_SDA_PIN; } static void fm_scl_input(void) { - GPIOB_DIR &= ~(1 << I2C_SCL_PIN); + I2C_GPIO_DIR &= ~(1 << I2C_SCL_PIN); } static void fm_scl_output(void) { - GPIOB_DIR |= 1 << I2C_SCL_PIN; + I2C_GPIO_DIR |= 1 << I2C_SCL_PIN; } static int fm_sda(void) { - return GPIOB_PIN(I2C_SDA_PIN); + return I2C_GPIO(I2C_SDA_PIN); } static int fm_scl(void) { - return GPIOB_PIN(I2C_SCL_PIN); + return I2C_GPIO(I2C_SCL_PIN); } /* simple and crude delay, used for all delays in the generic i2c driver */ @@ -96,7 +109,13 @@ static void fm_delay(void) /* interface towards the generic i2c driver */ static struct i2c_interface fm_i2c_interface = { +#if defined(SANSA_CLIP) .address = 0x10 << 1, +#elif defined(SANSA_M200V4) + .address = 0xC0, +#elif +#error no fm i2c address defined +#endif .scl_hi = fm_scl_hi, .scl_lo = fm_scl_lo, |