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
Eeprom.h
1 #pragma once
2 #include <vector>
3 #include <fstream>
4 
16 class Eeprom {
17 public:
21  struct Settings {
25  unsigned int bus;
30  char address;
39  unsigned int offset;
43  unsigned int maxLength;
44  };
45  Eeprom() {};
50  Eeprom(const Settings& settings);
56  int setup(const Settings& settings);
64  int read(unsigned int start = 0, unsigned int length = -1);
73  int write(unsigned int start = 0, unsigned int length = -1);
82  bool isSynced();
87  char* data();
88  const char* data() const;
92  size_t size() const;
97  char& operator[](std::size_t idx)
98  {
99  return content[idx];
100  }
105  const char& operator[](std::size_t idx) const {
106  return content[idx];
107  }
108 private:
109  int prepareToReadWrite(unsigned int start, unsigned int& length);
110  std::vector<char> content;
111  std::vector<char> writtenContent;
112  std::fstream file;
113  unsigned int offset;
114 };
int read(unsigned int start=0, unsigned int length=-1)
Definition: Eeprom.cpp:56
unsigned int maxLength
Definition: Eeprom.h:43
Definition: Eeprom.h:16
char * data()
Definition: Eeprom.cpp:41
int setup(const Settings &settings)
Definition: Eeprom.cpp:15
char address
Definition: Eeprom.h:30
const char & operator[](std::size_t idx) const
Definition: Eeprom.h:105
bool isSynced()
Definition: Eeprom.cpp:92
unsigned int offset
Definition: Eeprom.h:39
size_t size() const
Definition: Eeprom.cpp:51
int write(unsigned int start=0, unsigned int length=-1)
Definition: Eeprom.cpp:67
Definition: Eeprom.h:21
char & operator[](std::size_t idx)
Definition: Eeprom.h:97
unsigned int bus
Definition: Eeprom.h:25