nicolaielectronics/eeprom

2.0.1

Latest
uploaded 5 days ago
Library for reading and writing I2C EEPROM memory

Readme

# ESP-IDF component for for I2C EEPROM

An ESP-IDF component for communicating with I2C EEPROM memory chips.

## Usage

### Creating the EEPROM configuration struct

For AT24CS64 (page size of 32 bytes, 8-bit data addressing):

```
eeprom_configuration_t configuration = {
    .device = i2c_device_handle,
    .page_size = 16,
    .address_16bit = false,
    .timeout_ms = 100,
};
```

For AT24C512 (page size of 128 bytes, 16-bit data addressing):

```
eeprom_configuration_t configuration = {
    .device = i2c_device_handle,
    .page_size = 128,
    .address_16bit = true,
    .timeout_ms = 100,
};
```

### Reading from an EEPROM

```
uint8_t data[128];

esp_err_t res = eeprom_read(&configuration, 0, data, sizeof(data));
if (res == ESP_OK) {
    printf("Read data from EEPROM: ");
    for (size_t i = 0; i < sizeof(data); i++) {
        printf("%02X ");
    }
    printf("\r\n");
} else {
    printf("Failed to read from EEPROM (%u)\r\n", res);
}
```

### Writing to an EEPROM

```
uint8_t data[128];
for (size_t i = 0; i < sizeof(data); i++) data[i] = i; // Fill buffer with test pattern

esp_err_t res = eeprom_write(&configuration, 0, data, sizeof(data)); // Write 128 bytes to EEPROM at data address 0
if (res == ESP_OK) {
    printf("Data written to EEPROM\r\n");
} else {
    printf("Failed to write to EEPROM (%u)\r\n", res);
}
```

Links

Supports all targets

To add this component to your project, run:

idf.py add-dependency "nicolaielectronics/eeprom^2.0.1"

download archive

Stats

  • Archive size
    Archive size ~ 9.99 KB
  • Downloaded in total
    Downloaded in total 1.3k times
  • Weekly Downloads Weekly Downloads (All Versions)
  • Downloaded this version
    This version: 3 times

Badge

nicolaielectronics/eeprom version: 2.0.1
|