projects
/
gps-watch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8a92870
)
common: Implement Storage::read() in Mx25l.
author
Tilman Sauerbeck
<tilman@code-monkey.de>
Sun, 5 Jan 2020 17:53:58 +0000
(18:53 +0100)
committer
Tilman Sauerbeck
<tilman@code-monkey.de>
Wed, 8 Jan 2020 11:06:51 +0000
(12:06 +0100)
src/common/mx25l.rs
patch
|
blob
|
history
diff --git
a/src/common/mx25l.rs
b/src/common/mx25l.rs
index 6e74f4ac006bf52dfae59b808882f0981e21e3ac..24f9c36cb5a4f91d346ea69cc1c1c8eb8f86a45a 100644
(file)
--- a/
src/common/mx25l.rs
+++ b/
src/common/mx25l.rs
@@
-23,6
+23,7
@@
use gpio;
use spi;
use gpio;
use spi;
+use storage::Storage;
pub struct Mx25l {
cs_gpio: u32,
pub struct Mx25l {
cs_gpio: u32,
@@
-30,6
+31,7
@@
pub struct Mx25l {
}
enum Command {
}
enum Command {
+ READ = 0x03,
RDSR = 0x05,
RDID = 0x9f,
}
RDSR = 0x05,
RDID = 0x9f,
}
@@
-74,3
+76,19
@@
impl Mx25l {
r
}
}
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);
+ }
+ })
+ }
+}