From c8d03a43c61cbcfc15441dd33a11e4a5b8f0c02f Mon Sep 17 00:00:00 2001 From: Astro Date: Sat, 18 Jan 2020 00:59:11 +0100 Subject: [PATCH] libboard_zynq::flash: keep spi_en=1 over multiple manual transfers --- libboard_zynq/src/flash/mod.rs | 7 +++++++ libboard_zynq/src/flash/transfer.rs | 10 +--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libboard_zynq/src/flash/mod.rs b/libboard_zynq/src/flash/mod.rs index 12bb9dc..65466c3 100644 --- a/libboard_zynq/src/flash/mod.rs +++ b/libboard_zynq/src/flash/mod.rs @@ -326,6 +326,11 @@ impl Flash<()> { .lq_mode(false) ); + self.regs.enable.write( + regs::Enable::zeroed() + .spi_en(true) + ); + self.transition() } } @@ -351,6 +356,8 @@ impl Flash { impl Flash { pub fn stop(self) -> Flash<()> { + self.regs.enable.modify(|_, w| w.spi_en(false)); + self.transition() } diff --git a/libboard_zynq/src/flash/transfer.rs b/libboard_zynq/src/flash/transfer.rs index 53f0996..03f8bb0 100644 --- a/libboard_zynq/src/flash/transfer.rs +++ b/libboard_zynq/src/flash/transfer.rs @@ -13,10 +13,6 @@ pub struct Transfer<'a, Args: Iterator, W: Into> { impl<'a, Args: Iterator, W: Into> Transfer<'a, Args, W> { pub fn new(flash: &'a mut Flash, args: Args, len: usize) -> Self { flash.regs.config.modify(|_, w| w.pcs(false)); - flash.regs.enable.write( - regs::Enable::zeroed() - .spi_en(true) - ); let mut xfer = Transfer { flash, @@ -97,11 +93,7 @@ impl<'a, Args: Iterator, W: Into> Drop for Transfer<'a, Args, self.read(); } - // Stop - self.flash.regs.enable.write( - regs::Enable::zeroed() - .spi_en(false) - ); + self.flash.regs.config.modify(|_, w| w .pcs(true) .man_start_com(false)