/* This function does the actual read of the EEPROM. It needs the buffer into which the read data is copied, the size of the EEPROM being read and the buffer size  */
int read_eeprom(char *buffer, int eeprom_size, int size)
/* This function does the actual read of the EEPROM. It needs the buffer into which the read data is copied, the size of the EEPROM being read and the buffer size  */
int read_eeprom(char *buffer, int eeprom_size, int size)
{
	int	i = 0, err;
	send_start();
	send_byte(W_HEADER);
	recv_ack();
	if (eeprom_size > 2048) {
		send_byte(0x00);
		recv_ack();
	}
	send_start();
	send_byte(R_HEADER);
	err = recv_ack();
	if (err == -1)
		return err;
	for (i = 0; i < size; i++) {
		*buffer++ = recv_byte();
		send_ack();
	}
	send_stop();
}