use gpio;
use spi;
+use storage::Storage;
pub struct Mx25l {
cs_gpio: u32,
}
enum Command {
+ READ = 0x03,
RDSR = 0x05,
RDID = 0x9f,
}
r
}
}
+
+impl Storage for Mx25l {
+ fn read(&self, address: usize, buffer: &mut [u8]) {
+ self.with_selected(|| {
+ spi::tx8(spi::SPI0, Command::READ as u8);
+
+ spi::tx8(spi::SPI0, (address >> 16) as u8);
+ spi::tx8(spi::SPI0, (address >> 8) as u8);
+ spi::tx8(spi::SPI0, (address >> 0) as u8);
+
+ for i in 0..buffer.len() {
+ buffer[i] = spi::tx8(spi::SPI0, 0xff);
+ }
+ })
+ }
+}