Files
hsb/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/MemoryDevice.h
mmi 4901cb1a09 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
2017-11-02 12:58:27 +00:00

148 lines
4.6 KiB
C

// -----------------------------------------------------------------------------
/// @file MemoryDevice.h
/// @brief File 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) 2015 Micro-Key bv
// -----------------------------------------------------------------------------
/// @defgroup {group_name} {group_description}
/// Description
/// @file MemoryDevice.h
/// @ingroup {group_name}
#ifndef INC_MEMORYDEVICE_H_
#define INC_MEMORYDEVICE_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include <stdbool.h>
#include "stm32f10x.h"
// -----------------------------------------------------------------------------
// 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);
typedef ErrorStatus (*MemoryWriteFunction)(const struct MemoryDevice* self, uint32_t* buffer, uint32_t address, unsigned int length);
typedef ErrorStatus (*MemoryErasePageFunction)(const struct MemoryDevice* self, unsigned int page);
struct MemoryDevice
{
bool initialized;
bool needsEraseBeforeWrite;
MemoryReadFunction _read;
MemoryWriteFunction _write;
MemoryErasePageFunction _erasePage;
uint32_t startAddress;
uint32_t endAddress;
uint32_t pageSize;
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
/** ----------------------------------------------------------------------------
* MemoryDevice_construct
* Description of function
*
* @param self
* @param startAddress
* @return ErrorStatus
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus MemoryDevice_construct(struct MemoryDevice* self, uint32_t startAddress, uint32_t endAddress, uint32_t pageSize, bool needsEraseBeforeWrite, MemoryReadFunction read, MemoryWriteFunction write, MemoryErasePageFunction erasePage);
/** ----------------------------------------------------------------------------
* MemoryDevice_destruct
* Description of function
*
* @param self
* @param
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void MemoryDevice_destruct(struct MemoryDevice* self);
/** ----------------------------------------------------------------------------
* MemoryDevice_read
* Description of function
*
* @param self
* @param buffer
* @param address
* @param length
*
* @return ErrorStatus
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus MemoryDevice_write(const struct MemoryDevice* self, uint32_t* buffer, uint32_t address, unsigned int length);
/** ----------------------------------------------------------------------------
* MemoryDevice_read
* Description of function
*
* @param self
* @param buffer
* @param address
* @param length
*
* @return ErrorStatus
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus MemoryDevice_read(const struct MemoryDevice* self, uint32_t* buffer, uint32_t address, unsigned int length);
/** ----------------------------------------------------------------------------
* MemoryDevice_erasePage
* Description of function
*
* @param self
* @param page
* @return ErrorStatus
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus MemoryDevice_erasePage(struct MemoryDevice* self, unsigned int page);
#endif /* INC_MEMORYDEVICE_H_ */