/* Find the sector for the starting page */
dObj->sectorNumber = bufferObj->blockStart / pagesPerSector;
/* Find the number of sectors to be updated in this block. */
dObj->blockOffsetInSector = (bufferObj->blockStart % pagesPerSector);
dObj->nBlocksToWrite = (pagesPerSector - dObj->blockOffsetInSector);
if (bufferObj->nBlocks < dObj->nBlocksToWrite)
{
dObj->nBlocksToWrite = bufferObj->nBlocks;
}
if (dObj->nBlocksToWrite != pagesPerSector)
{
dObj->writePtr = dObj->ewBuffer;
dObj->ewState = DRV_MEMORY_EW_READ_SECTOR;
}
else
{
dObj->writePtr = bufferObj->buffer;
dObj->ewState = DRV_MEMORY_EW_ERASE_SECTOR;
transferStatus = MEMORY_DEVICE_TRANSFER_BUSY;
// ==> Missing break <==
break; // Here the flow must skip the next case because there is no need to read back the flash content
}
/* Fall through for read operation. */
}
In _DRV_MEMORYHandleEraseWrite the _DRV_MEMORY_EWINIT case has a missing break when dObj->nBlocksToWrite == pagesPerSector
`case DRV_MEMORY_EW_INIT: default: { dObj->readState = DRV_MEMORY_READ_INIT; dObj->eraseState = DRV_MEMORY_ERASE_INIT; dObj->writeState = DRV_MEMORY_WRITE_INIT;
case DRV_MEMORY_EW_READ_SECTOR: {...`