Exemple #1
0
    def __init__(self, clock, MOSI=None, MISO=None):
        if agnostic.detector.board.any_embedded_linux:
            # TODO: Attempt to load this library automatically
            raise NotImplementedError(
                "For bitbangio on Linux, please use Adafruit_CircuitPython_BitbangIO"
            )
        from machine import SPI as _SPI

        self._spi = _SPI(-1)
        self._pins = (clock, MOSI, MISO)
Exemple #2
0
 def __init__(self, clock, MOSI=None, MISO=None, *, baudrate=1000000):
     self._frequency = baudrate
     for portId, portSck, portMosi, portMiso in spiPorts:
         if ((clock == portSck)
                 and MOSI in (portMosi, None)  # Clock is required!
                 and MISO in (portMiso, None)  # But can do with just output
             ):  # Or just input
             mosiPin = Pin(portMosi.id) if MOSI else None
             misoPin = Pin(portMiso.id) if MISO else None
             self._spi = _SPI(
                 portId,
                 sck=Pin(portSck.id),
                 mosi=mosiPin,
                 miso=misoPin,
                 baudrate=baudrate,
             )
             break
     else:
         raise ValueError(
             "No Hardware SPI on (SCLK, MOSI, MISO)={}\nValid SPI ports:{}".
             format((clock, MOSI, MISO), spiPorts))
Exemple #3
0
 def __init__(self, portId, baudrate=100000):
     self._frequency = baudrate
     self._spi = _SPI(portId)