implemented memory device, flashStorage and cached storage
git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@268 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file MemoryDevice.c
|
||||
/// @brief Description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2017 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @file MemoryDevice.c
|
||||
/// @ingroup {group_name}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
#include "MemoryDevice.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// File-scope variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
ErrorStatus MemoryDevice_construct(struct MemoryDevice* self, uint32_t startAddress, uint32_t endAddress, MemoryReadFunction read, MemoryWriteFunction write, MemoryErasePageFunction erasePage)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
self->_read = read;
|
||||
self->_write = write;
|
||||
self->_erasePage = erasePage;
|
||||
self->startAddress = startAddress;
|
||||
self->endAddress = endAddress;
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void MemoryDevice_destruct(struct MemoryDevice* self)
|
||||
{
|
||||
self->_read = NULL;
|
||||
self->_write = NULL;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus MemoryDevice_write(const struct MemoryDevice* self, uint32_t* buffer, uint32_t address, unsigned int length)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (self->_write != NULL)
|
||||
{
|
||||
returnValue = self->_write(self, buffer, address, length);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus MemoryDevice_read(const struct MemoryDevice* self, uint32_t* buffer, uint32_t address, unsigned int length)
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (self->_read != NULL)
|
||||
{
|
||||
returnValue = self->_read(self, buffer, address, length);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
ErrorStatus MemoryDevice_erasePage(struct MemoryDevice* self, unsigned int page)
|
||||
{
|
||||
{
|
||||
ErrorStatus returnValue = SUCCESS;
|
||||
|
||||
if (self->_erasePage != NULL)
|
||||
{
|
||||
returnValue = self->_erasePage(self, page);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user