diff --git a/App/driver/py25q16.c b/App/driver/py25q16.c index 11e5f737..3d9990a1 100644 --- a/App/driver/py25q16.c +++ b/App/driver/py25q16.c @@ -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; } -} \ No newline at end of file +} diff --git a/archive/f4hwn.fusion.development.bin b/archive/f4hwn.fusion.development.bin index 54cce14f..242c0493 100755 Binary files a/archive/f4hwn.fusion.development.bin and b/archive/f4hwn.fusion.development.bin differ