//*****************************************************************************
//
// EEPROMdriver.c - Knihovna pro ovladani EEPROM
//
//*****************************************************************************

#include <I2Cdriver.h>
#include <EEPROMdriver.h>
#include <hw_types.h>
#include <sysctl.h>

//Promenne------------------
unsigned char Buff[EEPROM_BUFF_SIZE];

//Definice funkci*****************************************************
//Zapis jednoho bytu do EEPROM--------------------------------------
void EEPROMByteWrite(unsigned char address, unsigned char *data)
{
  Buff[0]=address;
  Buff[1]=*data;
  I2C_Write(ADDRESS_EEPROM, &Buff[0], 2);
}


//Cteni jednoho bytu z EEPROM---------------------------------------
void EEPROMByteRead(unsigned char address, unsigned char *data)
{
    I2C_Read(address, &data[0], (EEPROM | 1)); 
}

//Cteni vice bytu z EEPROM------------------------------------------
void EEPROMRead(unsigned char address, unsigned char *data, unsigned char count)
{ 
    for(int i=0;i<count;i++)
    {
      I2C_Read(address+i, &data[i], (EEPROM | 1));
    }
}

//Zapis vice bytu do EEPROM-----------------------------------------
void EEPROMWrite(unsigned char address, unsigned char *data, unsigned char count)
{
 
    for(int i=0;i<count;i++)
    {
      Buff[0]=address++;
      Buff[1]=*data++;
      I2C_Write(ADDRESS_EEPROM, &Buff[0], 2);
      SysCtlDelay(85000);
    }
}
