Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
CC32xxEEPROMEmulation.hxx
Go to the documentation of this file.
1
34#ifndef _FREERTOS_DRIVERS_TI_CC32XXEEPROMEMULATION_HXX_
35#define _FREERTOS_DRIVERS_TI_CC32XXEEPROMEMULATION_HXX_
36
37//#define FLASH_SIZE CC32xx_EEPROM_SIZE
38#include "EEPROMEmulation.hxx"
40
70{
71public:
76 CC32xxEEPROMEmulation(const char *name, size_t file_size_bytes);
77
81
83 void flush() {
86 }
87
90 void mount();
91
92private:
100 void write(unsigned int index, const void *buf, size_t len) override;
101
107 void read(unsigned int index, void *buf, size_t len) override;
108
117 int open_file(
118 unsigned sector, uint32_t open_mode, bool ignore_error = false);
119
121 void flush_buffers() OVERRIDE;
122
123private:
125 static const uint8_t SECTOR_COUNT;
126
130 unsigned fileVersion_{0};
131
133 uint8_t readSector_{0xff};
134
136 uint8_t isDirty_{0};
137
139 uint8_t *data_;
140};
141
142#endif // _FREERTOS_DRIVERS_TI_CC32XXEEPROMEMULATION_HXX_
Emulates EEPROM in SPI-FLASH for the CC32xx platform.
uint8_t isDirty_
non-zero if we have unflushed writes.
void mount()
Must be called exactly once after creation, after the simplelink stack has been started.
uint8_t * data_
Holds the file payload in memory.
int open_file(unsigned sector, uint32_t open_mode, bool ignore_error=false)
Opens a SL file.
void flush()
Instructs the driver to write all changed data to disk.
void flush_buffers() OVERRIDE
REQUIRED: lock_ is held.
void write(unsigned int index, const void *buf, size_t len) override
Write to the EEPROM.
void read(unsigned int index, void *buf, size_t len) override
Read from the EEPROM.
static const uint8_t SECTOR_COUNT
The total number of files which we are round-robining.
uint8_t readSector_
The sector number of the last sector we used for reading.
unsigned fileVersion_
This number is increased by one every time the contents are flushed to a file.
Common base class for all EEPROM access.
Definition EEPROM.hxx:44
const char * name
device name
Definition Devtab.hxx:266
OSMutex lock_
protects internal structures.
Definition Devtab.hxx:588
Class to allow convenient locking and unlocking of mutexes in a C context.
Definition OS.hxx:494
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
Definition macros.h:180