-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimFlashStorage.h
62 lines (48 loc) · 1.33 KB
/
SimFlashStorage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma once
#include <ConfigurableFirmata.h>
// This class simulates flash by memory. This is not within the #ifdef SIM to simplify development.
class VirtualFlashMemory
{
private:
byte* _memoryBasePtr;
uint32_t _memorySize;
public:
VirtualFlashMemory(size_t size);
~VirtualFlashMemory();
byte* readAddress(uint32_t address);
byte* getFirstFreeBlock();
uint32_t getFlashSize();
uint32_t getFlashPageSize()
{
return 4096;
}
void eraseBlock(uint32_t address, uint32_t length);
uint32_t getOffset(byte* address)
{
return address - _memoryBasePtr;
}
void MapFlash()
{
// Nothing to do
}
void UnmapFlash()
{
// Nothing to do
}
/// <summary>
/// Write a block to flash
/// </summary>
/// <param name="address">Address, relative to start of flash</param>
/// <param name="data">Pointer to data</param>
/// <param name="dataLength">Length of data</param>
/// <returns>True on success, false otherwise</returns>
boolean write(uint32_t address, byte* data, uint32_t dataLength);
/// <summary>
/// Write a block to flash
/// </summary>
/// <param name="address">Address, absolute</param>
/// <param name="data">Pointer to data</param>
/// <param name="dataLength">Length of data</param>
/// <returns>True on success, false otherwise</returns>
boolean write(byte* address, byte* data, uint32_t dataLength);
};