From 810fc22cf43b5cd504279f89e509a2a08d07481b Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Wed, 8 Jan 2020 10:40:49 +0100 Subject: [PATCH] common: Implement Mx25l::erase_all(). --- src/common/mx25l.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/common/mx25l.rs b/src/common/mx25l.rs index a6ad395..388d311 100644 --- a/src/common/mx25l.rs +++ b/src/common/mx25l.rs @@ -39,6 +39,7 @@ enum Command { RDSR = 0x05, WREN = 0x06, SE = 0x20, + CE = 0x60, RDID = 0x9f, } @@ -72,6 +73,17 @@ impl Mx25l { }) } + pub fn erase_all(&self) { + self.write_enable(); + + self.with_selected(|| { + spi::tx8(spi::SPI0, Command::CE as u8); + }); + + while self.write_in_progress() { + } + } + pub fn erase_sector(&self, address: usize) -> Result<(), Error> { if (address & (SECTOR_SIZE - 1)) != 0 { return Err(Error::UnalignedAddress); -- 2.30.2