mirror of
https://github.com/armel/uv-k1-k5v3-firmware-custom.git
synced 2026-10-02 03:15:37 +00:00
Avoid unnecessary flash sector erases
This commit is contained in:
1 parent
222448e1ad
commit
c9da65117f
2 files changed
+6
-2
No files matched your search
@@ -284,9 +284,13 @@ void PY25Q16_WriteBuffer(uint32_t Address, const void *pBuffer, uint32_t Size, b
|
||||
if (0 != memcmp(pBuffer, (char *)SectorCache + SecOffset, SecSize))
|
||||
{
|
||||
bool Erase = false;
|
||||
const uint8_t *oldData = SectorCache + SecOffset;
|
||||
const uint8_t *newData = (const uint8_t *)pBuffer;
|
||||
|
||||
for (uint32_t i = 0; i < SecSize; i++)
|
||||
{
|
||||
if (0xff != SectorCache[SecOffset + i])
|
||||
// NOR flash programming can only change bits from 1 to 0.
|
||||
if ((oldData[i] & newData[i]) != newData[i])
|
||||
{
|
||||
Erase = true;
|
||||
break;
|
||||
@@ -491,4 +495,4 @@ void DMA1_Channel4_5_6_7_IRQHandler()
|
||||
|
||||
TC_Flag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in new issue
Block a user