From fbcc3778d27cfbeec7a1395c9b13a00c8a26af9a Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Wed, 23 Jun 2021 12:48:13 +0800 Subject: [PATCH] spi: Always delay for NSS setup time * Fixes the lack of setup time delay of an fixed-byte command that immediately follows an N-byte command. * Extra 50ns will be inserted in-between fixed-byte commands but should be acceptable. --- src/spi.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/spi.rs b/src/spi.rs index d43964c..29e8a25 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -199,13 +199,7 @@ impl , self.nss.set_low(); // >=50ns min. CS_n setup time #[cfg(feature = "cortex-m-cpu")] - match opcode { - opcodes::RCRU | opcodes::WCRU | - opcodes::RRXDATA | opcodes::WGPDATA => { - cortex_m::asm::delay((0.05*(self.cpu_freq_mhz+1.)) as u32); - } - _ => { } - } + cortex_m::asm::delay((0.05*(self.cpu_freq_mhz+1.)) as u32); // Start writing to SLAVE buf[0] = opcode; let result = self.spi.transfer(&mut buf[..data_length+1]);