Skip to content

Commit

Permalink
feature: allow miso to be absent from SpiBus
Browse files Browse the repository at this point in the history
  • Loading branch information
Clyde Laforge committed Jun 20, 2024
1 parent a80b812 commit e35a1a5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cocotbext/spi/spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from typing import Tuple

import cocotb
from cocotb.binary import BinaryValue
from cocotb.clock import BaseClock
from cocotb.triggers import Edge
from cocotb.triggers import Event
Expand Down Expand Up @@ -60,9 +61,13 @@ def __init__(self, bus: SpiBus, config: SpiConfig) -> None:
# spi signals
self._sclk = bus.sclk
self._mosi = bus.mosi
self._miso = bus.miso
self._cs = bus.cs

if hasattr(bus, 'miso'):
self._miso = bus.miso
else:
self._miso = BinaryValue()

# size of a transfer
self._config = config

Expand Down Expand Up @@ -236,9 +241,13 @@ def __init__(self, bus: SpiBus):

self._sclk = bus.sclk
self._mosi = bus.mosi
self._miso = bus.miso
self._cs = bus.cs

if hasattr(bus, 'miso'):
self._miso = bus.miso
else:
self._miso = BinaryValue()

self._miso.value = self._config.data_output_idle

self.idle = Event()
Expand Down

0 comments on commit e35a1a5

Please sign in to comment.