From 53eebce39cabe4e779886251276d0d97eab89031 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 ddb6d3d..0353c4b 100644 --- a/libboard_zynq/src/flash/mod.rs +++ b/libboard_zynq/src/flash/mod.rs @@ -340,6 +340,11 @@ impl Flash<()> { .lq_mode(false) ); + self.regs.enable.write( + regs::Enable::zeroed() + .spi_en(true) + ); + self.transition() } } @@ -365,6 +370,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)