summaryrefslogtreecommitdiff
path: root/firmware/drivers/i2c.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/i2c.c')
-rw-r--r--firmware/drivers/i2c.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/firmware/drivers/i2c.c b/firmware/drivers/i2c.c
index ed12145da9..71cb9cf8b0 100644
--- a/firmware/drivers/i2c.c
+++ b/firmware/drivers/i2c.c
@@ -50,7 +50,7 @@
50#define SDA_HI or_b(0x80, &PBDRL) 50#define SDA_HI or_b(0x80, &PBDRL)
51#define SDA_INPUT and_b(~0x80, &PBIORL) 51#define SDA_INPUT and_b(~0x80, &PBIORL)
52#define SDA_OUTPUT or_b(0x80, &PBIORL) 52#define SDA_OUTPUT or_b(0x80, &PBIORL)
53#define SDA (PBDR & 0x80) 53#define SDA (PBDRL & 0x80)
54 54
55#if CONFIG_I2C == I2C_ONDIO 55#if CONFIG_I2C == I2C_ONDIO
56/* Ondio pinout, SCL moved to PB6 */ 56/* Ondio pinout, SCL moved to PB6 */
@@ -58,14 +58,14 @@
58#define SCL_OUTPUT or_b(0x40, &PBIORL) 58#define SCL_OUTPUT or_b(0x40, &PBIORL)
59#define SCL_LO and_b(~0x40, &PBDRL) 59#define SCL_LO and_b(~0x40, &PBDRL)
60#define SCL_HI or_b(0x40, &PBDRL) 60#define SCL_HI or_b(0x40, &PBDRL)
61#define SCL (PBDR & 0x0040) 61#define SCL (PBDRL & 0x40)
62#else 62#else
63/* "classic" pinout, SCL is PB13 */ 63/* "classic" pinout, SCL is PB13 */
64#define SCL_INPUT and_b(~0x20, &PBIORH) 64#define SCL_INPUT and_b(~0x20, &PBIORH)
65#define SCL_OUTPUT or_b(0x20, &PBIORH) 65#define SCL_OUTPUT or_b(0x20, &PBIORH)
66#define SCL_LO and_b(~0x20, &PBDRH) 66#define SCL_LO and_b(~0x20, &PBDRH)
67#define SCL_HI or_b(0x20, &PBDRH) 67#define SCL_HI or_b(0x20, &PBDRH)
68#define SCL (PBDR & 0x2000) 68#define SCL (PBDRH & 0x20)
69#endif 69#endif
70#endif /* ! I2C_GMINI */ 70#endif /* ! I2C_GMINI */
71 71
@@ -109,22 +109,14 @@ void i2c_init(void)
109#if CONFIG_I2C == I2C_GMINI 109#if CONFIG_I2C == I2C_GMINI
110 SCL_INPUT; 110 SCL_INPUT;
111 SDA_INPUT; 111 SDA_INPUT;
112#else 112#elif CONFIG_I2C == I2C_ONDIO
113#if CONFIG_I2C == I2C_ONDIO 113 /* make PB6 & PB7 general I/O */
114 /* make PB5, PB6 & PB7 general I/O */ 114 PBCR2 &= ~0xf000;
115 PBCR2 &= ~0xfc00; /* includes PB5, see FIXME below */
116#else /* not Gmini, not Ondio */ 115#else /* not Gmini, not Ondio */
117 /* make PB5, PB7 & PB13 general I/O */ 116 /* make PB7 & PB13 general I/O */
118 PBCR1 &= ~0x0c00; /* PB13 */ 117 PBCR1 &= ~0x0c00; /* PB13 */
119 PBCR2 &= ~0xcc00; /* PB5 and PB7, see FIXME below */ 118 PBCR2 &= ~0xc000; /* PB7 */
120#endif 119#endif
121
122 /* PB5 is "MAS enable" (no I2C signal!). make it output and high */
123 /* FIXME: this is true only for Players, and should go into mas.c */
124 /* for Recorders, it shuts off the charger, for FM/V2 it holds power */
125 or_b(0x20, &PBIORL);
126 or_b(0x20, &PBDRL);
127#endif /* end of non-Gmini */
128 120
129 SCL_OUTPUT; 121 SCL_OUTPUT;
130 SDA_OUTPUT; 122 SDA_OUTPUT;