CSRField("sel", len(self.cs), reset=1, description="Write ``1`` to corresponding bit to enable Xfer for chip.")
], description="SPI Chip Select.")
self._loopback = CSRStorage(description="SPI loopback mode.\n\n Write ``1`` to enable MOSI to MISO internal loopback.")
- self._clk_divider = CSRStorage(16, description="SPI Clk Divider.", reset=self.clk_divider.reset)
self.comb += [
self.start.eq(self._control.fields.start),
self.mosi.eq(self._mosi.storage),
self.cs.eq(self._cs.storage),
self.loopback.eq(self._loopback.storage),
- self.clk_divider.eq(self._clk_divider.storage),
self._status.fields.done.eq(self.done),
self._miso.status.eq(self.miso),
]
+ def add_clk_divider(self):
+ self._clk_divider = CSRStorage(16, description="SPI Clk Divider.", reset=self.clk_divider.reset)
+ self.comb += self.clk_divider.eq(self._clk_divider.storage)
+
# SPI Slave ----------------------------------------------------------------------------------------
class SPISlave(Module):
if hasattr(pads, "rst"):
self.comb += pads.rst.eq(0)
spisdcard = SPIMaster(pads, 8, self.sys_clk_freq, 400e3)
+ spisdcard.add_clk_divider()
setattr(self.submodules, name, spisdcard)
self.add_csr(name)