[go: up one dir, main page]

Skip to content

Two-Wire Serial EEPROM Access Library for RaspberryPi

Notifications You must be signed in to change notification settings

nopnop2002/Raspberry-at24c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raspberry-at24c

Two-Wire Serial EEPROM Access Library for RaspberryPi.

I forked from eeprog-0.7.6-tear5.tar.gz


Memory size

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

Build

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.


  • 24C04
    24c04

  • 24C16
    24c16

  • 24C32
    24c32

  • 24C64
    24c64

  • 24C128
    24c128

  • 24C256
    24c256

  • 24C512
    24c512


API

// 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);

Wireing

A0 A1 A2 is used to select i2c address.
When A0 A1 A2 is GND, i2c address is 0x50.

24cxx