core/spi: make cs_n optional (sometimes managed externally)

This commit is contained in:
Florent Kermarrec 2019-07-05 19:18:52 +02:00
parent e726ad80ac
commit 77e7f9b3c1
1 changed files with 5 additions and 3 deletions

View File

@ -30,7 +30,8 @@ class SPIMaster(Module, AutoCSR):
self._status = CSRStatus(1)
self._mosi = CSRStorage(data_width)
self._miso = CSRStatus(data_width)
self._cs = CSRStorage(len(pads.cs_n), reset=1)
if hasattr(pads, "cs_n"):
self._cs = CSRStorage(len(pads.cs_n), reset=1)
self.irq = Signal()
@ -101,8 +102,9 @@ class SPIMaster(Module, AutoCSR):
)
# Chip Select generation -------------------------------------------------------------------
for i in range(len(pads.cs_n)):
self.comb += pads.cs_n[i].eq(~self._cs.storage[i] | ~cs)
if hasattr(pads, "cs_n"):
for i in range(len(pads.cs_n)):
self.comb += pads.cs_n[i].eq(~self._cs.storage[i] | ~cs)
# Master Out Slave In (MOSI) generation (generated on spi_clk falling edge) ---------------
mosi_data = Signal(data_width)