For a flash chip I'm using, the time to do a 64KB block erase is significantly faster than a whole series of sector erase commands. For 1MB, this is about 800ms vs 7500ms.
I'd be happy to send a PR to add support for erasing blocks, but wanted to first check your thoughts on API.
One option would be to add a new method that just erases a 64KB block. e.g.:
fn erase_64k_block(&mut self, addr: u32) -> Result<(), Error<SPI, CS>> {
self.write_enable()?;
let mut cmd_buf = [
Opcode::BlockErase as u8,
(addr >> 16) as u8,
(addr >> 8) as u8,
addr as u8,
];
self.command(&mut cmd_buf)?;
self.wait_done()
}
Another option would be to change erase_sectors to check if you're erasing all the sectors in a block and if so, erase that block instead. This has the advantage that it doesn't add to the API, but it does make the implementation of erase_sectors more complex. Any preference?
For a flash chip I'm using, the time to do a 64KB block erase is significantly faster than a whole series of sector erase commands. For 1MB, this is about 800ms vs 7500ms.
I'd be happy to send a PR to add support for erasing blocks, but wanted to first check your thoughts on API.
One option would be to add a new method that just erases a 64KB block. e.g.:
Another option would be to change
erase_sectors
to check if you're erasing all the sectors in a block and if so, erase that block instead. This has the advantage that it doesn't add to the API, but it does make the implementation of erase_sectors more complex. Any preference?