From 9fc4ffb1db7938130b02c43ab5a682e520a80b05 Mon Sep 17 00:00:00 2001 From: mndza Date: Wed, 11 Oct 2023 13:30:20 +0200 Subject: [PATCH] interface.flash: allow SPI buses without bidirectional chip select line --- luna/gateware/interface/flash.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/luna/gateware/interface/flash.py b/luna/gateware/interface/flash.py index d33d1c306..2f110799b 100644 --- a/luna/gateware/interface/flash.py +++ b/luna/gateware/interface/flash.py @@ -55,13 +55,16 @@ def elaborate(self, platform): self.bus.sdi .eq(self.sdi), self.sdo .eq(self.bus.sdo) ] - - if self.use_cs: - m.d.comb += [ - self.bus.cs.o.eq(self.cs), - self.bus.cs.oe.eq(1) - ] - else: - m.d.comb += self.bus.cs.oe.eq(0) + + if hasattr(self.bus.cs, "oe"): + if self.use_cs: + m.d.comb += [ + self.bus.cs.o.eq(self.cs), + self.bus.cs.oe.eq(1) + ] + else: + m.d.comb += self.bus.cs.oe.eq(0) + elif self.use_cs: + m.d.comb += self.bus.cs.eq(self.cs) return m