A5 = PC5/SCL
*/
-#define I2CM_SCL_PORT PORTC
-#define I2CM_SCL_BIT 5
+#define I2CM_SCL_PORT PORTD
+#define I2CM_SCL_BIT 6
-#define I2CM_SDA_PORT PORTC
-#define I2CM_SDA_BIT 4
+#define I2CM_SDA_PORT PORTD
+#define I2CM_SDA_BIT 5
#define I2CM_SCL I2CM_SCL_PORT, I2CM_SCL_BIT
#define I2CM_SDA I2CM_SDA_PORT, I2CM_SDA_BIT
}
-uint8_t i2cm_send_byte(uint8_t byte)
+static uint8_t i2cm_send_byte(uint8_t byte)
{
uint8_t mask;
uint8_t err = 0;
I2CM_DELAY();
mask >>=1;
- // delay needed ?
- //I2CM_DELAY();
-
// clock High
I2C_HIGH(I2CM_SCL_PORT, I2CM_SCL_BIT);
I2CM_DELAY();
I2CM_DELAY();
while ( bit_is_clear(PIN(I2CM_SCL_PORT), I2CM_SCL_BIT) );// slave handshake
- // receive ACK
- if (bit_is_set(I2CM_SDA_PORT, I2CM_SDA_BIT))
+ // we should receive ACK
+ if (bit_is_set(PIN(I2CM_SDA_PORT), I2CM_SDA_BIT))
err = I2CM_SENT_NO_ACK;
// clock low
}
-
-uint8_t i2c_send(uint8_t addr, uint8_t* data, uint8_t len, uint8_t ctrl)
+uint8_t i2cm_send(uint8_t addr, uint8_t* data, uint8_t len)
{
uint8_t i;
uint8_t err = 0;
- (void)ctrl; /* ignored */
-
err = i2cm_send_start((addr<<1) | 0);
if (err)
return err;
}
-uint8_t i2c_buf[0x20];
+uint8_t i2c_buf[0x20]; /* XXX */
-uint8_t i2c_recv(uint8_t addr, uint8_t len, uint8_t ctrl)
+uint8_t i2cm_recv(uint8_t addr, uint8_t len)
{
uint8_t i;
uint8_t err = 0;
- (void)ctrl; /* ignored */
-
err = i2cm_send_start((addr<<1) | 1);
if (err)
return err;
}
-uint8_t i2c_get_recv_buffer(uint8_t* buf, uint8_t len)
+uint8_t i2cm_get_recv_buffer(uint8_t* buf, uint8_t len)
{
uint8_t i;
for (i=0; i<len; i++)
buf[i] = i2c_buf[i];
return len;
}
-
-