Skip to content

SPI driver creating an usbiss instance. #14

@gwdehaan

Description

@gwdehaan
  • pyusbiss version: 0.2.2
  • Python version: 3.6
  • Operating System: Windows10

Description

SPI is the only usbiss mode that does not allow any coexistence with another protocol, as it uses all 4 available pins.
Therefore in the current implementation of SPI it made sense to open the COM port within the SPI driver.

What I Did

As I2C, Serial and GPIO can be used in combination with each other and therefor it is not possible to open usbiss within
The driver, you can only open the COM port once. These 3 drivers expect the user to instantiate a usbiss class and then pass on the instance to the driver.

Example

from usbiss import usbiss
from usbiss import gpio
from usbiss import i2c

port = 'COM3'
# open the COM port for the USBISS
usbissdev = usbiss.USBISS(port)
# use the GPIO in I2C mode (2 pins available for GPIO)
io2 = gpio.GPIO(usbissdev, gpio.I2C)
io2.setup(1, gpio.OUT)
io2.output(1, gpio.HIGH)
io2.setup(2, gpio.IN)
# Open an i2c channel
i2c_chan = I2C.I2C(usbissdev, 'H', 100)

Proposal

To prevent having 2 different driver architectures I would like to suggest to adapt the SPI driver to the same setup.

Current :

def __init__(self, port, mode=0, max_speed_hz=3000000):
    self._usbiss = USBISS(port)

Proposal :

def __init__(self, usbissdev, mode=0, max_speed_hz=3000000):
    self._usbiss = usbissdev

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions