Skip to content

Commit

Permalink
Adds implementation of chip_erase() to SpiFlash driver. (#676)
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsracz authored Nov 12, 2022
1 parent 62e836e commit 3f124a2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/freertos_drivers/common/SPIFlash.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,19 @@ void SPIFlash::erase(uint32_t addr, size_t len)
addr += cfg_->sectorSize_;
}
}

void SPIFlash::chip_erase()
{
struct spi_ioc_transfer xfer[2] = {0, 0};
xfer[0].tx_buf = (uintptr_t)&cfg_->writeEnableCommand_;
xfer[0].len = 1;
xfer[0].cs_change = true;
xfer[1].tx_buf = (uintptr_t)&cfg_->chipEraseCommand_;
xfer[1].len = 1;
xfer[1].cs_change = true;

::ioctl(spiFd_, SPI_IOC_MESSAGE(2), &xfer);

unsigned waitcount = wait_for_write();
LOG(INFO, "chip-erase, success after %u iter", waitcount);
}

0 comments on commit 3f124a2

Please sign in to comment.