summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-09-10 07:24:00 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-09-10 07:24:00 +0000
commit6c1afd7a9e128f2ff628e3e4d2584024c2d8951f (patch)
tree1649dd246c50891955aee1d9c3f8942458127155
parentd5c293a525e364f17b3cc9ec8eeb00c000796bc9 (diff)
downloadrockbox-6c1afd7a9e128f2ff628e3e4d2584024c2d8951f.tar.gz
rockbox-6c1afd7a9e128f2ff628e3e4d2584024c2d8951f.zip
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.c31
-rw-r--r--firmware/export/config-ondiofm.h7
-rw-r--r--firmware/export/config-ondiosp.h7
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 @@
23#include "debug.h" 23#include "debug.h"
24#include "system.h" 24#include "system.h"
25 25
26/*
27** SDA is PB7
28** SCL is PB13
29*/
30
31/* cute little functions, atomic read-modify-write */ 26/* cute little functions, atomic read-modify-write */
27/* SDA is PB7 */
32#define SDA_LO and_b(~0x80, &PBDRL) 28#define SDA_LO and_b(~0x80, &PBDRL)
33#define SDA_HI or_b(0x80, &PBDRL) 29#define SDA_HI or_b(0x80, &PBDRL)
34#define SDA_INPUT and_b(~0x80, &PBIORL) 30#define SDA_INPUT and_b(~0x80, &PBIORL)
35#define SDA_OUTPUT or_b(0x80, &PBIORL) 31#define SDA_OUTPUT or_b(0x80, &PBIORL)
36#define SDA (PBDR & 0x80) 32#define SDA (PBDR & 0x80)
37 33
34#ifdef HAVE_ONDIO_I2C
35/* Ondio pinout, SCL moved to PB6 */
36#define SCL_INPUT and_b(~0x40, &PBIORL)
37#define SCL_OUTPUT or_b(0x40, &PBIORL)
38#define SCL_LO and_b(~0x40, &PBDRL)
39#define SCL_HI or_b(0x40, &PBDRL)
40#define SCL (PBDR & 0x0040)
41#else
42/* "classic" pinout, SCL is PB13 */
38#define SCL_INPUT and_b(~0x20, &PBIORH) 43#define SCL_INPUT and_b(~0x20, &PBIORH)
39#define SCL_OUTPUT or_b(0x20, &PBIORH) 44#define SCL_OUTPUT or_b(0x20, &PBIORH)
40#define SCL_LO and_b(~0x20, &PBDRH) 45#define SCL_LO and_b(~0x20, &PBDRH)
41#define SCL_HI or_b(0x20, &PBDRH) 46#define SCL_HI or_b(0x20, &PBDRH)
42#define SCL (PBDR & 0x2000) 47#define SCL (PBDR & 0x2000)
48#endif
43 49
44/* arbitrary delay loop */ 50/* arbitrary delay loop */
45#define DELAY do { int _x; for(_x=0;_x<20;_x++);} while (0) 51#define DELAY do { int _x; for(_x=0;_x<20;_x++);} while (0)
@@ -78,17 +84,22 @@ void i2c_init(void)
78{ 84{
79 int i; 85 int i;
80 86
87#ifdef HAVE_ONDIO_I2C
88 /* make PB5, PB6 & PB7 general I/O */
89 PBCR2 &= ~0xfc00; /* includes PB5, see FIXME below */
90#else
81 /* make PB5, PB7 & PB13 general I/O */ 91 /* make PB5, PB7 & PB13 general I/O */
82 PBCR1 &= ~0x0c00; /* PB13 */ 92 PBCR1 &= ~0x0c00; /* PB13 */
83 PBCR2 &= ~0xcc00; /* PB5 abd PB7 */ 93 PBCR2 &= ~0xcc00; /* PB5 and PB7, see FIXME below */
94#endif
84 95
85 /* PB5 is "MAS enable". make it output and high */ 96 /* PB5 is "MAS enable" (no I2C signal!). make it output and high */
97 /* FIXME: this is true only for Players, and should go into mas.c */
98 /* for Recorders, it shuts off the charger, for FM/V2 it holds power */
86 or_b(0x20, &PBIORL); 99 or_b(0x20, &PBIORL);
87 or_b(0x20, &PBDRL); 100 or_b(0x20, &PBDRL);
88 101
89 /* Set the clock line PB13 to an output */ 102 SCL_OUTPUT;
90 or_b(0x20, &PBIORH);
91
92 SDA_OUTPUT; 103 SDA_OUTPUT;
93 SDA_HI; 104 SDA_HI;
94 SCL_LO; 105 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 @@
28/* Define this to the CPU frequency */ 28/* Define this to the CPU frequency */
29#define CPU_FREQ 12000000 29#define CPU_FREQ 12000000
30 30
31/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */ 31/* Battery scale factor (measured from rg's FM) */
32#define BATTERY_SCALE_FACTOR 8081 /* don't know yet */ 32#define BATTERY_SCALE_FACTOR 4785 /* 4.890V read as 0x3FE */
33 33
34/* Define this if you control power on PB5 (instead of the OFF button) */ 34/* Define this if you control power on PB5 (instead of the OFF button) */
35#define HAVE_POWEROFF_ON_PB5 /* don't know yet */ 35#define HAVE_POWEROFF_ON_PB5 /* don't know yet */
@@ -61,3 +61,6 @@
61/* Define this if the display is mounted upside down */ 61/* Define this if the display is mounted upside down */
62#define HAVE_DISPLAY_FLIPPED 62#define HAVE_DISPLAY_FLIPPED
63 63
64/* Define this for different I2C pinout */
65#define HAVE_ONDIO_I2C
66
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 @@
28/* Define this to the CPU frequency */ 28/* Define this to the CPU frequency */
29#define CPU_FREQ 12000000 29#define CPU_FREQ 12000000
30 30
31/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */ 31/* Battery scale factor (measured from rg's FM) */
32#define BATTERY_SCALE_FACTOR 8081 /* don't know yet */ 32#define BATTERY_SCALE_FACTOR 4785 /* 4.890V read as 0x3FE */
33 33
34/* Define this if you control power on PB5 (instead of the OFF button) */ 34/* Define this if you control power on PB5 (instead of the OFF button) */
35#define HAVE_POWEROFF_ON_PB5 /* don't know yet */ 35#define HAVE_POWEROFF_ON_PB5 /* don't know yet */
@@ -61,3 +61,6 @@
61/* Define this if the display is mounted upside down */ 61/* Define this if the display is mounted upside down */
62#define HAVE_DISPLAY_FLIPPED 62#define HAVE_DISPLAY_FLIPPED
63 63
64/* Define this for different I2C pinout */
65#define HAVE_ONDIO_I2C
66