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.

Return

0 on success, negative errno code on failure.

Parameters
  • dev: EEPROM device

  • offset: Address offset to read from.

  • data: Buffer to store read data.

  • len: Number of bytes to read.

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

Write data to EEPROM.

Return

0 on success, negative errno code on failure.

Parameters
  • dev: EEPROM device

  • offset: Address offset to write data to.

  • data: Buffer with data to write.

  • len: Number of bytes to write.

size_t eeprom_get_size(const struct device *dev)

Get the size of the EEPROM in bytes.

Return

EEPROM size in bytes.

Parameters
  • dev: EEPROM device.

struct eeprom_driver_api
#include <eeprom.h>