Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Classes | Public Member Functions | List of all members
Eeprom Class Reference

#include <Eeprom.h>

Classes

struct  Settings
 

Public Member Functions

 Eeprom (const Settings &settings)
 
int setup (const Settings &settings)
 
int read (unsigned int start=0, unsigned int length=-1)
 
int write (unsigned int start=0, unsigned int length=-1)
 
bool isSynced ()
 
char * data ()
 
const char * data () const
 
size_t size () const
 
char & operator[] (std::size_t idx)
 
const char & operator[] (std::size_t idx) const
 

Detailed Description

A class to read/write an EEPROM memory via i2c using the sysfs interface provided by the 24cXXX class of drivers.

The class maintains a copy in a memory buffer of the content of the EEPROM, which is read during setup() and subsequent calls to read(), and it assumes that no other program or device will write to the EEPROM in the meantime. The user shall access the memory buffer using [], data() and size(), modify it as needed, and then call write() to actually write the data to the hardware.

Constructor & Destructor Documentation

Eeprom::Eeprom ( const Settings settings)

Creates the object. It calls setup() and if the latter fails it will throw an exception of type std::runtime_error.

Member Function Documentation

int Eeprom::setup ( const Settings settings)

Sets up the object to access an EEPROM.

Returns
0 on success or an error code otherwise.
int Eeprom::read ( unsigned int  start = 0,
unsigned int  length = -1 
)

Read the content of the EEPROM into the memory buffer.

Parameters
startthe first byte to read.
lengthhow many bytes to read.
Returns
0 on success or an error code otherwise.
int Eeprom::write ( unsigned int  start = 0,
unsigned int  length = -1 
)

Write the content of the memory buffer to the EEPROM. If no arguments are passed, it will write the entire EEPROM.

Parameters
startthe first byte to write.
lengthhow many bytes to write.
Returns
0 on success or an error code otherwise.
bool Eeprom::isSynced ( )

Verify whether the latest version of the memory buffer has been written to the EEPROM. This does not actually re-read the content of the EEPROM, so it will not detect changes performed by others.

This internally performs a comparison between portions of memory of the size of the EEPROM, so it could be slow.

char * Eeprom::data ( )

Access a R/W pointer to the memory buffer. The number of elements that are accessible is returned by size().

size_t Eeprom::size ( ) const

Return the size of the EEPROM (and of the memory buffer).

char& Eeprom::operator[] ( std::size_t  idx)
inline

Access an element of the memory buffer. The number of elements that are accessible is returned by size().

const char& Eeprom::operator[] ( std::size_t  idx) const
inline

Access an element of the memory buffer. The number of elements that are accessible is returned by size().


The documentation for this class was generated from the following files: