forked from len0rd/rockbox
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
This commit is contained in:
parent
4ae9de5490
commit
02184a242e
2 changed files with 31 additions and 10 deletions
|
@ -1094,6 +1094,8 @@ target/arm/lcd-ssd1815.c
|
||||||
target/arm/as3525/sansa-m200v4/button-m200v4.c
|
target/arm/as3525/sansa-m200v4/button-m200v4.c
|
||||||
#ifndef BOOTLOADER
|
#ifndef BOOTLOADER
|
||||||
target/arm/as3525/powermgmt-as3525.c
|
target/arm/as3525/powermgmt-as3525.c
|
||||||
|
drivers/generic_i2c.c
|
||||||
|
target/arm/as3525/fmradio-i2c-as3525.c
|
||||||
#endif /* !BOOTLOADER */
|
#endif /* !BOOTLOADER */
|
||||||
#endif /* !SIMULATOR */
|
#endif /* !SIMULATOR */
|
||||||
#endif /* SANSA_M200V4 */
|
#endif /* SANSA_M200V4 */
|
||||||
|
|
|
@ -31,57 +31,70 @@
|
||||||
#include "generic_i2c.h"
|
#include "generic_i2c.h"
|
||||||
#include "fmradio_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_SCL_PIN 4
|
||||||
#define I2C_SDA_PIN 5
|
#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)
|
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)
|
static void fm_scl_lo(void)
|
||||||
{
|
{
|
||||||
GPIOB_PIN(I2C_SCL_PIN) = 0;
|
I2C_GPIO(I2C_SCL_PIN) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fm_sda_hi(void)
|
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)
|
static void fm_sda_lo(void)
|
||||||
{
|
{
|
||||||
GPIOB_PIN(I2C_SDA_PIN) = 0;
|
I2C_GPIO(I2C_SDA_PIN) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fm_sda_input(void)
|
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)
|
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)
|
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)
|
static void fm_scl_output(void)
|
||||||
{
|
{
|
||||||
GPIOB_DIR |= 1 << I2C_SCL_PIN;
|
I2C_GPIO_DIR |= 1 << I2C_SCL_PIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fm_sda(void)
|
static int fm_sda(void)
|
||||||
{
|
{
|
||||||
return GPIOB_PIN(I2C_SDA_PIN);
|
return I2C_GPIO(I2C_SDA_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fm_scl(void)
|
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 */
|
/* 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 */
|
/* interface towards the generic i2c driver */
|
||||||
static struct i2c_interface fm_i2c_interface = {
|
static struct i2c_interface fm_i2c_interface = {
|
||||||
|
#if defined(SANSA_CLIP)
|
||||||
.address = 0x10 << 1,
|
.address = 0x10 << 1,
|
||||||
|
#elif defined(SANSA_M200V4)
|
||||||
|
.address = 0xC0,
|
||||||
|
#elif
|
||||||
|
#error no fm i2c address defined
|
||||||
|
#endif
|
||||||
|
|
||||||
.scl_hi = fm_scl_hi,
|
.scl_hi = fm_scl_hi,
|
||||||
.scl_lo = fm_scl_lo,
|
.scl_lo = fm_scl_lo,
|
Loading…
Add table
Add a link
Reference in a new issue