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.
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
Proposal
To prevent having 2 different driver architectures I would like to suggest to adapt the SPI driver to the same setup.
Current \:
Proposal \: