/* Function Description: Send the address for write mode. * Return : None. */ static void envctrl_i2c_write_addr(unsigned char addr) { envctrl_i2c_test_bb(); envctrl_writeb(addr, &i2c->data); /* Generate Start condition. */ envctrl_writeb(OBD_SEND_START, &i2c->csr); }
/* Function Description: Send the address for write mode. * Return : None. */ static void envctrl_i2c_write_addr(unsigned char addr) { envctrl_i2c_test_bb(); writeb(addr, i2c + PCF8584_DATA); /* Generate Start condition. */ writeb(OBD_SEND_START, i2c + PCF8584_CSR); }
/* Function Description: Send the address for a read access. * Return : 0 if not acknowledged, otherwise acknowledged. */ static int envctrl_i2c_read_addr(unsigned char addr) { envctrl_i2c_test_bb(); /* Load address. */ envctrl_writeb(addr + 1, &i2c->data); envctrl_i2c_test_bb(); envctrl_writeb(OBD_SEND_START, &i2c->csr); /* Wait for PIN. */ envtrl_i2c_test_pin(); /* CSR 0 means acknowledged. */ if (!(envctrl_readb(&i2c->csr) & STATUS_LRB)) { return envctrl_readb(&i2c->data); } else { envctrl_writeb(OBD_SEND_STOP, &i2c->csr); return 0; } }
/* Function Description: Send the address for a read access. * Return : 0 if not acknowledged, otherwise acknowledged. */ static int envctrl_i2c_read_addr(unsigned char addr) { envctrl_i2c_test_bb(); /* Load address. */ writeb(addr + 1, i2c + PCF8584_DATA); envctrl_i2c_test_bb(); writeb(OBD_SEND_START, i2c + PCF8584_CSR); /* Wait for PIN. */ envtrl_i2c_test_pin(); /* CSR 0 means acknowledged. */ if (!(readb(i2c + PCF8584_CSR) & STATUS_LRB)) { return readb(i2c + PCF8584_DATA); } else { writeb(OBD_SEND_STOP, i2c + PCF8584_CSR); return 0; } }