User manual

I2C API reference
61 © 2007-2010 Analytica GmbH
I2CWriteEEPROM
I2CWriteEEPROM — Writes data to an I2C EEPROM.
Syntax
#include <AnaGateDllI2C.h>
int I2CWriteEEPROM(int hHandle, unsigned short nSubAddress, unsigned
int nOffset, const char * pcBuffer, int nBufferLen, unsigned int
nOffsetFormat);
Parameter
hHandle Valid access handle.
nSubAddress Subaddress of the EEPROM to communicate with. The valid values
for nSubAddress are governed by the setting used in the parameter
nOffsetFormat (bits 8-10). If the EEPROM type needs to use bits of the Chip
Enable Address to address the internal memory, only the remaining bits can be used
to select the device itself.
No bit is used for addressing: 0 to 7
1 bit is used for addressing: 0 to 3
2 bits are used for addressing: 0 to 1
3 bits are used for addressing: 0
nOffset Data offset on the EEPROM to which the transferred data is to be written.
pcBuffer Character string buffer with the data that is to be written.
nBufferLen Length of the data buffer.
nOffsetFormat Defines how a memory address of EEPROM has to be specified when accessing
the device.
Bits 0-7 indicate the number of bits which are used in the address byte (word) of the
I2C command for addressing the device memory.
Bits 8-10 indicate how much and which bits of the Chip Enable Bits are used for
addressing the device memory (see Table 6.1, Usage of the CHIP-Enable Bits of
I2C EEPROMs” for allowed values).
Note
The maximum addressable size of an EEPROM is derived from the
sum of all the bits. For example a M24C08 uses 8 bits of the address
byte and an extra bit in the slave address. The total 9 bits can address
up to 512 bytes.
Return value
Returns Null if successful, or an error value otherwise (Appendix A, Return Codes).