Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
EEPROM.hxx
Go to the documentation of this file.
1
34#ifndef _FREERTOS_DRIVERS_COMMON_EEPROM_HXX_
35#define _FREERTOS_DRIVERS_COMMON_EEPROM_HXX_
36
37#include <cstdint>
38
39#include "Devtab.hxx"
40
43class EEPROM : public Node
44{
45protected:
50 EEPROM(const char *name, size_t file_size)
51 : Node(name)
53 {
54 }
55
59 {
60 }
61
69 virtual void write(unsigned int index, const void *buf, size_t len) = 0;
70
76 virtual void read(unsigned int index, void *buf, size_t len) = 0;
77
81 size_t file_size()
82 {
83 return fileSize;
84 }
85
86private:
87 size_t fileSize;
96 int open(File* file, const char *path, int flags, int mode) OVERRIDE;
97
104 ssize_t read(File *file, void *buf, size_t count) OVERRIDE;
105
112 ssize_t write(File *file, const void *buf, size_t count) OVERRIDE;
113
121 off_t lseek(File* file, off_t offset, int whence) OVERRIDE;
122
123 void enable() OVERRIDE {}
124 void disable() OVERRIDE {};
128
132
134};
135
136#endif /* _FREERTOS_DRIVERS_COMMON_EEPROM_HXX_ */
137
Common base class for all EEPROM access.
Definition EEPROM.hxx:44
EEPROM()
Default constructor.
off_t lseek(File *file, off_t offset, int whence) OVERRIDE
Seek method.
Definition EEPROM.cxx:45
size_t fileSize
Maximum file size we can grow to.
Definition EEPROM.hxx:87
void enable() OVERRIDE
function to enable device
Definition EEPROM.hxx:123
virtual void read(unsigned int index, void *buf, size_t len)=0
Read from the EEPROM.
void flush_buffers() OVERRIDE
function to disable device
Definition EEPROM.hxx:127
~EEPROM()
Destructor.
Definition EEPROM.hxx:58
virtual void write(unsigned int index, const void *buf, size_t len)=0
Write to the EEPROM.
EEPROM(const char *name, size_t file_size)
Constructor.
Definition EEPROM.hxx:50
size_t file_size()
Get the maximum file size of the EEPROM file.
Definition EEPROM.hxx:81
int open(File *file, const char *path, int flags, int mode) OVERRIDE
Open a device.
Definition EEPROM.cxx:66
void disable() OVERRIDE
This will be called when reference count goes from non-zero to 0.
Definition EEPROM.hxx:124
const char * name
device name
Definition Devtab.hxx:266
Node information.
Definition Devtab.hxx:549
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
Definition macros.h:180
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
Definition macros.h:171
File information.
Definition Devtab.hxx:52