diff options
author | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-09-10 07:24:00 +0000 |
---|---|---|
committer | Jörg Hohensohn <hohensoh@rockbox.org> | 2004-09-10 07:24:00 +0000 |
commit | 6c1afd7a9e128f2ff628e3e4d2584024c2d8951f (patch) | |
tree | 1649dd246c50891955aee1d9c3f8942458127155 | |
parent | d5c293a525e364f17b3cc9ec8eeb00c000796bc9 (diff) |
adjustment for the Ondio: I2C clock is on a different pin
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5054 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | firmware/drivers/i2c.c | 31 | ||||
-rw-r--r-- | firmware/export/config-ondiofm.h | 7 | ||||
-rw-r--r-- | firmware/export/config-ondiosp.h | 7 |
3 files changed, 31 insertions, 14 deletions
diff --git a/firmware/drivers/i2c.c b/firmware/drivers/i2c.c index 2fc53d579f..673f7f7e61 100644 --- a/firmware/drivers/i2c.c +++ b/firmware/drivers/i2c.c @@ -23,23 +23,29 @@ #include "debug.h" #include "system.h" -/* -** SDA is PB7 -** SCL is PB13 -*/ - /* cute little functions, atomic read-modify-write */ +/* SDA is PB7 */ #define SDA_LO and_b(~0x80, &PBDRL) #define SDA_HI or_b(0x80, &PBDRL) #define SDA_INPUT and_b(~0x80, &PBIORL) #define SDA_OUTPUT or_b(0x80, &PBIORL) #define SDA (PBDR & 0x80) +#ifdef HAVE_ONDIO_I2C +/* Ondio pinout, SCL moved to PB6 */ +#define SCL_INPUT and_b(~0x40, &PBIORL) +#define SCL_OUTPUT or_b(0x40, &PBIORL) +#define SCL_LO and_b(~0x40, &PBDRL) +#define SCL_HI or_b(0x40, &PBDRL) +#define SCL (PBDR & 0x0040) +#else +/* "classic" pinout, SCL is PB13 */ #define SCL_INPUT and_b(~0x20, &PBIORH) #define SCL_OUTPUT or_b(0x20, &PBIORH) #define SCL_LO and_b(~0x20, &PBDRH) #define SCL_HI or_b(0x20, &PBDRH) #define SCL (PBDR & 0x2000) +#endif /* arbitrary delay loop */ #define DELAY do { int _x; for(_x=0;_x<20;_x++);} while (0) @@ -78,17 +84,22 @@ void i2c_init(void) { int i; +#ifdef HAVE_ONDIO_I2C + /* make PB5, PB6 & PB7 general I/O */ + PBCR2 &= ~0xfc00; /* includes PB5, see FIXME below */ +#else /* make PB5, PB7 & PB13 general I/O */ PBCR1 &= ~0x0c00; /* PB13 */ - PBCR2 &= ~0xcc00; /* PB5 abd PB7 */ + PBCR2 &= ~0xcc00; /* PB5 and PB7, see FIXME below */ +#endif - /* PB5 is "MAS enable". make it output and high */ + /* PB5 is "MAS enable" (no I2C signal!). make it output and high */ + /* FIXME: this is true only for Players, and should go into mas.c */ + /* for Recorders, it shuts off the charger, for FM/V2 it holds power */ or_b(0x20, &PBIORL); or_b(0x20, &PBDRL); - /* Set the clock line PB13 to an output */ - or_b(0x20, &PBIORH); - + SCL_OUTPUT; SDA_OUTPUT; SDA_HI; SCL_LO; diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h index 24effa08e4..0f71ea6113 100644 --- a/firmware/export/config-ondiofm.h +++ b/firmware/export/config-ondiofm.h @@ -28,8 +28,8 @@ /* Define this to the CPU frequency */ #define CPU_FREQ 12000000 -/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */ -#define BATTERY_SCALE_FACTOR 8081 /* don't know yet */ +/* Battery scale factor (measured from Jörg's FM) */ +#define BATTERY_SCALE_FACTOR 4785 /* 4.890V read as 0x3FE */ /* Define this if you control power on PB5 (instead of the OFF button) */ #define HAVE_POWEROFF_ON_PB5 /* don't know yet */ @@ -61,3 +61,6 @@ /* Define this if the display is mounted upside down */ #define HAVE_DISPLAY_FLIPPED +/* Define this for different I2C pinout */ +#define HAVE_ONDIO_I2C + diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h index 3abb4a8b05..8e2a9d6e0f 100644 --- a/firmware/export/config-ondiosp.h +++ b/firmware/export/config-ondiosp.h @@ -28,8 +28,8 @@ /* Define this to the CPU frequency */ #define CPU_FREQ 12000000 -/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */ -#define BATTERY_SCALE_FACTOR 8081 /* don't know yet */ +/* Battery scale factor (measured from Jörg's FM) */ +#define BATTERY_SCALE_FACTOR 4785 /* 4.890V read as 0x3FE */ /* Define this if you control power on PB5 (instead of the OFF button) */ #define HAVE_POWEROFF_ON_PB5 /* don't know yet */ @@ -61,3 +61,6 @@ /* Define this if the display is mounted upside down */ #define HAVE_DISPLAY_FLIPPED +/* Define this for different I2C pinout */ +#define HAVE_ONDIO_I2C + |