
/*!
 * \file i2c_eeprom.h
 * \ingroup i2c_eep
 * \brief Routinen zur Ansteuerung eines EEPROMs über I2C (Header-File)
 */

#ifndef __I2C_EEPROM__
#define __I2C_EEPROM__

// I2C-Headerfile einbinden für Statusdefinitionen etc.
#include <util/twi.h>

//! Taktfrequenz für I2C SCL
#define SCL_CLOCK               400000L


// Schreib- und Lesebefehle
// ---------------------------------------------------------
// Bits:  | MSB |  6  |  5  |  4  |  3  |  2  |  1  | LSB |
//        |  1  |  0  |  1  |  0  |  A2 |  A1 |  A0 | R/W |

#define FC256_READ_CMD          0xA1            // Lese-Kommando für den 24FC256
#define FC256_WRITE_CMD         0xA0            // Schreib-Kommando für den 24FC256


// EEPROM-Routinen
uint8_t i2cEepromReadSequential(uint16_t addr, uint8_t * buf, uint8_t len);
uint8_t i2cEepromReadCurrent(uint8_t * buf, uint8_t len);
uint8_t i2cEepromWriteByte(uint16_t addr, uint8_t data);
uint8_t i2cEepromWritePage(uint16_t addr, uint8_t * buf, uint8_t len);

// I2C-Routinen
void i2cInit(void);
uint8_t i2cStart(uint8_t addr);
void i2cStop(void);
uint8_t i2cWrite(uint8_t data);
uint8_t i2cRead(uint8_t ack);

#endif
