Updated memory storage functionality

- cachedStorage is functional
- Presets can be loaded from FLASH
- CRC32 added and applied
- Presets with corrputed data will be replaced by default preset

Next: Preset update functionality from menu 

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@269 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-11-02 12:58:27 +00:00
parent 76783a6061
commit 4901cb1a09
27 changed files with 894 additions and 144 deletions

View File

@@ -38,11 +38,14 @@
// Constant and macro definitions
// -----------------------------------------------------------------------------
#define MEMORY_DEVICE_NEEDS_ERASE_BEFORE_WRITE (true)
#define MEMORY_DEVICE_NEEDS_NO_ERASE_BEFORE_WRITE (false)
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
struct MemoryDevice;
typedef ErrorStatus (*MemoryReadFunction)(const struct MemoryDevice* self, uint32_t* buffer, uint32_t address, unsigned int length);
@@ -51,11 +54,14 @@ typedef ErrorStatus (*MemoryErasePageFunction)(const struct MemoryDevice* self,
struct MemoryDevice
{
bool initialized;
bool needsEraseBeforeWrite;
MemoryReadFunction _read;
MemoryWriteFunction _write;
MemoryErasePageFunction _erasePage;
uint32_t startAddress;
uint32_t endAddress;
uint32_t pageSize;
};
// -----------------------------------------------------------------------------
@@ -74,7 +80,7 @@ struct MemoryDevice
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus MemoryDevice_construct(struct MemoryDevice* self, uint32_t startAddress, uint32_t endAddress, MemoryReadFunction read, MemoryWriteFunction write, MemoryErasePageFunction erasePage);
extern ErrorStatus MemoryDevice_construct(struct MemoryDevice* self, uint32_t startAddress, uint32_t endAddress, uint32_t pageSize, bool needsEraseBeforeWrite, MemoryReadFunction read, MemoryWriteFunction write, MemoryErasePageFunction erasePage);
/** ----------------------------------------------------------------------------