From dd3ad3be670f31dce45f7eabb8d796b278a6381e Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 29 Nov 2019 23:48:08 +0100 Subject: [PATCH] zynq::flash: implement stopping LinearAddressing mode --- src/zynq/flash/mod.rs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/zynq/flash/mod.rs b/src/zynq/flash/mod.rs index 3866f37..2f886a4 100644 --- a/src/zynq/flash/mod.rs +++ b/src/zynq/flash/mod.rs @@ -19,6 +19,15 @@ pub struct Flash { _mode: PhantomData, } +impl Flash { + fn transition(self) -> Flash { + Flash { + regs: self.regs, + _mode: PhantomData, + } + } +} + impl Flash<()> { pub fn new(clock: u32) -> Self { Self::enable_clocks(clock); @@ -185,15 +194,25 @@ impl Flash<()> { self.regs.enable.modify(|_, w| w.spi_en(true)); - Flash { - regs: self.regs, - _mode: PhantomData, - } + self.transition() } } impl Flash { + /// Stop linear addressing mode + pub fn stop(self) -> Flash<()> { + self.regs.enable.modify(|_, w| w.spi_en(false)); + // De-assert chip select. + self.regs.config.modify(|_, w| w.pcs(true)); + + self.transition() + } + pub fn ptr(&mut self) -> *mut T { 0xFC00_0000 as *mut _ } + + pub fn size(&self) -> usize { + 32 * 1024 * 1024 + } }