static int get_slave_ack(void) { int r; sda_high(); scl_high(); r = read_sda(); scl_low(); return r; } static int send_byte(unsigned char byte) { int i; // SCL is currently low // Send byte in MSB first order for(i = 7; i >=0; i--) { if (byte & (1 << i)) sda_high(); else sda_low(); scl_high(); scl_low(); } // Now get the acknowledgement. return get_slave_ack(); }