Two-Wire Serial EEPROM Access Library for RaspberryPi.
I forked from eeprog-0.7.6-tear5.tar.gz
Device | Number of Bits | Number of 8-bit Bytes | i2c address |
---|---|---|---|
24C02 | 2K | 256 | 0x50-0x57 |
24C04 | 4K | 512 | 0x50/0x52/0x54/0x56 |
24C08 | 8K | 1024 | 0x50/0x54 |
24C16 | 16K | 2048 | 0x50 |
24C32 | 32K | 4096 | 0x50-0x57 |
24C64 | 64K | 8192 | 0x50-0x57 |
24C128 | 128K | 16384 | 0x50-0x57 |
24C256 | 256K | 32768 | 0x50-0x57 |
24C512 | 512K | 65536 | 0x50-0x57 |
for 24C02
cc -o main main.c at24c.c -DC02
for 24C04
cc -o main main.c at24c.c -DC04
for 24C08
cc -o main main.c at24c.c -DC08
for 24C16
cc -o main main.c at24c.c -DC16
for 24C32
cc -o main main.c at24c.c -DC32
for 24C64
cc -o main main.c at24c.c -DC64
for 24C128
cc -o main main.c at24c.c -DC128
for 24C256
cc -o main main.c at24c.c -DC256
for 24C512
cc -o main main.c at24c.c -DC512
sudo ./main [i2c-address]
Default i2c-address is 0x50.
// Open device
int eeprom_open(char *dev_fqn, int i2c_addr, int bits, int delay, struct eeprom*);
// Get EEPROM memory size
__u16 getEEPROMbytes(struct eeprom* e);
// Read data from EEPROM
int eeprom_read_byte(struct eeprom* e, __u16 mem_addr);
// Write data to EEPROM
int eeprom_write_byte(struct eeprom *e, __u16 mem_addr, __u8 data);
A0 A1 A2 is used to select i2c address.
When A0 A1 A2 is GND, i2c address is 0x50.