X-Git-Url: http://git.droids-corp.org/?p=protos%2Fimu.git;a=blobdiff_plain;f=i2cm_sw.c;h=a7da2b560f14f1aa6d5fe7e26e51511516f84be8;hp=78f562d1ce2935d6da0a8e80ff1a43ad03a82d0f;hb=950c56ac3c1e5651f54965700f385076ab63c8ea;hpb=25c697a7feaf4f0fbba4e3cab8bb13132753c37d diff --git a/i2cm_sw.c b/i2cm_sw.c index 78f562d..a7da2b5 100644 --- a/i2cm_sw.c +++ b/i2cm_sw.c @@ -49,11 +49,11 @@ void (*g_i2cm_event)(i2cm_state state); 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 @@ -112,7 +112,7 @@ void i2cm_register_event(void (*func)(i2cm_state state)) } -uint8_t i2cm_send_byte(uint8_t byte) +static uint8_t i2cm_send_byte(uint8_t byte) { uint8_t mask; uint8_t err = 0; @@ -136,9 +136,6 @@ uint8_t i2cm_send_byte(uint8_t byte) I2CM_DELAY(); mask >>=1; - // delay needed ? - //I2CM_DELAY(); - // clock High I2C_HIGH(I2CM_SCL_PORT, I2CM_SCL_BIT); I2CM_DELAY(); @@ -160,8 +157,8 @@ uint8_t i2cm_send_byte(uint8_t byte) 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 @@ -282,8 +279,7 @@ uint8_t i2cm_receive_byte(uint8_t last) } - -uint8_t i2c_send(uint8_t addr, uint8_t* data, uint8_t len, uint8_t dummy) +uint8_t i2cm_send(uint8_t addr, uint8_t* data, uint8_t len) { uint8_t i; uint8_t err = 0; @@ -303,9 +299,9 @@ uint8_t i2c_send(uint8_t addr, uint8_t* data, uint8_t len, uint8_t dummy) } -uint8_t i2c_buf[0x20]; +uint8_t i2c_buf[0x20]; /* XXX */ -uint8_t i2c_recv(uint8_t addr, uint8_t len, uint8_t dummy) +uint8_t i2cm_recv(uint8_t addr, uint8_t len) { uint8_t i; uint8_t err = 0; @@ -327,12 +323,10 @@ uint8_t i2c_recv(uint8_t addr, uint8_t len, uint8_t dummy) } -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