Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
|
#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 |
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.
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
.
int Eeprom::setup | ( | const Settings & | settings | ) |
Sets up the object to access an EEPROM.
int Eeprom::read | ( | unsigned int | start = 0 , |
unsigned int | length = -1 |
||
) |
Read the content of the EEPROM into the memory buffer.
start | the first byte to read. |
length | how many bytes to read. |
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.
start | the first byte to write. |
length | how many bytes to write. |
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).
|
inline |
Access an element of the memory buffer. The number of elements that are accessible is returned by size().
|
inline |
Access an element of the memory buffer. The number of elements that are accessible is returned by size().