Hi, Gaurav,
I see your question, I am sure that the uint32_t EraseSectors(uint32_t adr, uint32_t numsecs) call the blockerase command.
If you want to implement the sector erase function, I suppose you have to implement it yourself. Because the LPC43xx is a bit old, in the latest spifi flash operation for LPC54xxx, we do not use the QSPI Flash Drivers architecture, so it is impossible to update QSPI Flash Drivers in future I think.
Hope it can help you
BR
XiangJun Rong
uint32_t EraseSectors(uint32_t adr, uint32_t numsecs) {
SPIFI_ERR_T errCode;
#if !defined (DONT_BLANKCHECK_BEFORE_ERASING)
uint8_t ch = FlashDevice.valEmpty;
uint32_t chw = ch | (ch << | (ch << 16) | (ch << 24);
if (checkblank(adr,(numsecs * (FlashDevice.sectors[0].szSector/4)), chw ) == 0)
return (0); // sector blank, so no need to erase
#endif
spifiDevSetMemMode(pSpifiHandle, false);
errCode = spifiEraseByAddr(pSpifiHandle, adr, adr + (FlashDevice.sectors[0].szSector * (numsecs -1)));
if (errCode != SPIFI_ERR_NONE)
return (errCode);
spifiDevSetMemMode(pSpifiHandle, true);
return (0);
}
/* Erase multiple blocks */
SPIFI_ERR_T spifiErase(const SPIFI_HANDLE_T *pHandle, uint32_t firstBlock, uint32_t numBlocks)
{
SPIFI_ERR_T err = SPIFI_ERR_NONE;
if ((firstBlock + numBlocks) > pHandle->pInfoData->numBlocks) {
return SPIFI_ERR_RANGE;
}
/* Only perform erase if numBlocks is != 0 */
for (; (numBlocks); ++firstBlock, --numBlocks) {
err = pHandle->pFamFx->eraseBlock(pHandle, firstBlock);
if (err != SPIFI_ERR_NONE) {
break;
}
}
return err;
}
/* Erase multiple blocks by address range */
SPIFI_ERR_T spifiEraseByAddr(const SPIFI_HANDLE_T *pHandle, uint32_t firstAddr, uint32_t lastAddr)
{
uint32_t firstBlock, lastBlock;
SPIFI_ERR_T err = SPIFI_ERR_RANGE;
/* Get block numbers for addresses */
firstBlock = spifiGetBlockFromAddr(pHandle, firstAddr);
lastBlock = spifiGetBlockFromAddr(pHandle, lastAddr);
/* Limit to legal address range */
if ((firstBlock != ~0UL) && (lastBlock != ~0UL)) {
err = spifiErase(pHandle, firstBlock, ((lastBlock - firstBlock) + 1));
}
return err;
}