zynq::flash: implement stopping LinearAddressing mode
This commit is contained in:
parent
a8a7f11990
commit
dd3ad3be67
|
@ -19,6 +19,15 @@ pub struct Flash<MODE> {
|
||||||
_mode: PhantomData<MODE>,
|
_mode: PhantomData<MODE>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<MODE> Flash<MODE> {
|
||||||
|
fn transition<TO>(self) -> Flash<TO> {
|
||||||
|
Flash {
|
||||||
|
regs: self.regs,
|
||||||
|
_mode: PhantomData,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Flash<()> {
|
impl Flash<()> {
|
||||||
pub fn new(clock: u32) -> Self {
|
pub fn new(clock: u32) -> Self {
|
||||||
Self::enable_clocks(clock);
|
Self::enable_clocks(clock);
|
||||||
|
@ -185,15 +194,25 @@ impl Flash<()> {
|
||||||
|
|
||||||
self.regs.enable.modify(|_, w| w.spi_en(true));
|
self.regs.enable.modify(|_, w| w.spi_en(true));
|
||||||
|
|
||||||
Flash {
|
self.transition()
|
||||||
regs: self.regs,
|
|
||||||
_mode: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Flash<LinearAddressing> {
|
impl Flash<LinearAddressing> {
|
||||||
|
/// 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<T>(&mut self) -> *mut T {
|
pub fn ptr<T>(&mut self) -> *mut T {
|
||||||
0xFC00_0000 as *mut _
|
0xFC00_0000 as *mut _
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn size(&self) -> usize {
|
||||||
|
32 * 1024 * 1024
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue