The latest development version of this page may be more current than this released 2.7.5 version.

EEPROM

Overview

The EEPROM API provides read and write access to Electrically Erasable Programmable Read-Only Memory (EEPROM) devices.

EEPROMs have an erase block size of 1 byte, a long lifetime, and allow overwriting data on byte-by-byte access.

Configuration Options

Related configuration options:

API Reference

group eeprom_interface

EEPROM Interface.

Typedefs

typedef int (*eeprom_api_read)(const struct device *dev, off_t offset, void *data, size_t len)
typedef int (*eeprom_api_write)(const struct device *dev, off_t offset, const void *data, size_t len)
typedef size_t (*eeprom_api_size)(const struct device *dev)

Functions

int eeprom_read(const struct device *dev, off_t offset, void *data, size_t len)

Read data from EEPROM.

Parameters
  • dev – EEPROM device

  • offset – Address offset to read from.

  • data – Buffer to store read data.

  • len – Number of bytes to read.

Returns

0 on success, negative errno code on failure.

int eeprom_write(const struct device *dev, off_t offset, const void *data, size_t len)

Write data to EEPROM.

Parameters
  • dev – EEPROM device

  • offset – Address offset to write data to.

  • data – Buffer with data to write.

  • len – Number of bytes to write.

Returns

0 on success, negative errno code on failure.

size_t eeprom_get_size(const struct device *dev)

Get the size of the EEPROM in bytes.

Parameters
  • dev – EEPROM device.

Returns

EEPROM size in bytes.

struct eeprom_driver_api
#include <eeprom.h>