mirror of
https://github.com/thelsing/knx.git
synced 2025-07-30 13:46:26 +02:00
add commitNonVolatileMemory overload to batch write chars n times to flash
This commit is contained in:
parent
9894a8c8b8
commit
6a1b70c558
@ -201,6 +201,37 @@ uint32_t Platform::writeNonVolatileMemory(uint32_t relativeAddress, uint8_t* buf
|
||||
}
|
||||
}
|
||||
|
||||
// writes value repeat times into flash starting at relativeAddress
|
||||
// returns next free relativeAddress
|
||||
uint32_t Platform::writeNonVolatileMemory(uint32_t relativeAddress, uint8_t value, size_t repeat)
|
||||
{
|
||||
if(_memoryType == Flash)
|
||||
{
|
||||
while (repeat > 0)
|
||||
{
|
||||
loadEraseblockContaining(relativeAddress);
|
||||
uint32_t start = _bufferedEraseblockNumber * (flashEraseBlockSize() * flashPageSize());
|
||||
uint32_t end = start + (flashEraseBlockSize() * flashPageSize());
|
||||
|
||||
uint32_t offset = relativeAddress - start;
|
||||
uint32_t length = end - relativeAddress;
|
||||
if(length > repeat)
|
||||
length = repeat;
|
||||
memset(_eraseblockBuffer + offset, value, length);
|
||||
_bufferedEraseblockDirty = true;
|
||||
|
||||
relativeAddress += length;
|
||||
repeat -= length;
|
||||
}
|
||||
return relativeAddress;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(getEepromBuffer(KNX_FLASH_SIZE)+relativeAddress, value, repeat);
|
||||
return relativeAddress+repeat;
|
||||
}
|
||||
}
|
||||
|
||||
void Platform::loadEraseblockContaining(uint32_t relativeAddress)
|
||||
{
|
||||
int32_t blockNum = getEraseBlockNumberOf(relativeAddress);
|
||||
|
@ -70,6 +70,7 @@ class Platform
|
||||
virtual void commitNonVolatileMemory();
|
||||
// address is relative to start of nonvolatile memory
|
||||
virtual uint32_t writeNonVolatileMemory(uint32_t relativeAddress, uint8_t* buffer, size_t size);
|
||||
virtual uint32_t writeNonVolatileMemory(uint32_t relativeAddress, uint8_t value, size_t repeat);
|
||||
|
||||
NvMemoryType NonVolatileMemoryType();
|
||||
void NonVolatileMemoryType(NvMemoryType type);
|
||||
|
Loading…
Reference in New Issue
Block a user