SmartWaveAPI package
Module contents
An API for Semify’s SmartWave.
Subpackages
- SmartWaveAPI.configitems package
- SmartWaveAPI.definitions package
Submodules
SmartWaveAPI.smartwave module
- class SmartWaveAPI.smartwave.SmartWave
Bases:
object
An instance of a SmartWave device. Keeps track of all available resources.
- FPGABitstreamEnd = 4503599627370495
- FPGABitstreamStart = 0
- FPGAClockDivided: int = 1525.9021896696422
- FPGAClockSpeed: int = 100000000.0
- FirmwareEnd = 98816
- FirmwareStart = 36864
- PID: int = 32881
- SBLStart = 8192
- VID: int = 9025
- configGeneral(vddio: float | None = None, triggerMode: TriggerMode | None = None)
Configure general information on the connected device.
- Parameters:
vddio (float) – The IO voltage of the connected device (accurate to 0.01V)
triggerMode (TriggerMode) – The trigger mode of the output device (i.e. whether it runs once or continuously)
- Raises:
AttributeError – if vddio is not betweeen 1.8V and 5.0V
- connect(portName: str = None, reset: bool = True, requestInfo: bool = True, configureGeneral: bool = True)
Try to connect to a SmartWave device at the specified port.
- Parameters:
portName (str) – The name of the port to connect to
reset (bool) – Reset the device after connection
requestInfo (bool) – Request info from the device after connection
configureGeneral (bool) – Configure general with the default values
- Returns:
Self
- Return type:
- Raises:
ConnectionRefusedError – If no connection could be established with the specified port
raises AttributeError: If the device at the specified port is not a SmartWave device
- createI2CConfig(sdaPinName: str | None = None, sclPinName: str | None = None, clockSpeed: int | None = None) I2CConfig
Create an I2C Configuration object.
- Parameters:
sdaPinName (str) – The name of the pin to use for SDA
sclPinName (str) – The name of the pin to use for SCL
clockSpeed (int) – The I2C clock speed in Hz
- Returns:
An I2C Configuration with the specified settings
- Return type:
- createSPIConfig(sclkPinName: str | None = None, mosiPinName: str | None = None, misoPinName: str | None = None, ssPinName: str | None = None, clockSpeed: int | None = None, bitWidth: int | None = None, bitNumbering: Literal['MSB', 'LSB'] | None = None, cspol: Literal[0, 1] | None = None, cpol: Literal[0, 1] | None = None, cphase: Literal[0, 1] | None = None)
Create an SPI Configuration object.
- Parameters:
sclkPinName (str) – The name of the pin to use for SCLK
mosiPinName (str) – The name of the pin to use for MOSI
misoPinName (str) – The name of the pin to use for MISO
ssPinName (str) – The name of the pin to use for SS
clockSpeed (int) – The transmission clock speed in Hz
bitWidth (int) – The bit width of the SPI transmissions
bitNumbering (Literal["MSB", "LSB"]) – Whether to transmit MSB-first or LSB-first
cspol (Literal[0, 1]) – The polarity of the chipselect pin
cpol (Literal[0, 1]) – The polarity of the clock pin
cphase (Literal[0, 1]) – The phase of the clock
- Returns:
An SPI Configuration with the specified settings
- Return type:
SPIConfig
- disconnect()
Disconnect from the connected device.
- getNextAvailableI2CDriver() I2CDriver
Get the next available I2C Driver.
- Returns:
An I2C Driver, which has already been marked as in use
- Return type:
- Raises:
Exception – If no more I2C Drivers are available on the device
- getNextAvailablePin() Pin
Get the next available Pin.
- Returns:
A Pin, which has already been marked as in use
- Return type:
- Raises:
Exception – If no more Pins are available on the device
- getNextAvailableSPIDriver() SPIDriver
Get the next available SPI Driver.
- Returns:
An SPI Driver, which has already been marked as in use
- Return type:
SPIDriver
- Raises:
Exception – If no more SPI Drivers are available on the device
- getNextAvailableStimulus() Stimulus
Get the next available stimulus.
- Returns:
A Stimulus, which has already been marked as in use
- Return type:
- Raises:
Exception – If no more Stimuli are available on the device
- getPin(name: str) Pin
Get a pin by its name.
- Parameters:
name (str) – The pin’s name
- Returns:
The specified pin, which has already been marked as in use
- Return type:
- Raises:
AttributeError – If the pin name does not exist on the device
Exception – If the pin is already in use
- isConnected() bool
Return whether a device connection is currently active.
- Returns:
True if the device is connected, False otherwise
- readFPGARegister(address: int, blocking: bool = True) int | None
Read directly from a register on the SmartWave’s FPGA.
- Parameters:
address (int) – The address to read from
blocking (bool) – If true, wait for the response from the connected device
- Returns:
If blocking == True, return the content of the specified register. Else return None.
- Return type:
Union[int, None]
- Raises:
Exception – If the blocking mode is requested and another callback for a register read operation
is already registered
- removeConfig(config: Config)
Remove a config from the device.
- Parameters:
config (Config) – the config to remove
- Raises:
AttributeError – If the config is not found
- requestInfo()
Request the device information from the connected device.
- reset()
Reset the configuration of the connected device.
- returnI2CDriver(driver: I2CDriver) int
Return an I2C Driver to the list of available I2C Drivers.
- Parameters:
driver (I2CDriver) – The I2C driver to return
- Returns:
The new number of available I2C Drivers
- Return type:
int
- returnPin(pin: Pin) int
Return a Pin to the list of available pins.
- Parameters:
pin (Pin) – The pin to return
- Returns:
The new number of available pins
rtype: int
- returnSPIDriver(driver: SPIDriver) int
Return an SPI Driver to the list of available SPI Drivers.
- Parameters:
driver (SPIDriver) – The SPI driver to return
- Returns:
The new number of available SPI drivers
- Return type:
int
- returnStimulus(stimulus: Stimulus) int
Return a stimulus to the list of available stimuli.
- Parameters:
stimulus (Stimulus) – The stimulus to return
- Returns:
The new number of available stimuli
- Return type:
int
- scanAndConnect(reset: bool = True, requestInfo: bool = True, configureGeneral: bool = True)
Scan all serial ports on the PC and connect to a SmartWave device if one is found.
- Parameters:
reset (bool) – Reset the device after connection
requestInfo (bool) – Request info from the device after connection
configureGeneral (bool) – Configure general with the default values
- Returns:
Self
- Return type:
- Raises:
ConnectionRefusedError – If no suitable device is found
- trigger()
Start or Stop the current configuration on the connected device.
- property triggerMode: TriggerMode
Get the current trigger mode of the connected device.
- Returns:
The current trigger mode of the connected device
- Return type:
- updateFPGABitstream(bitstreamPath: str | None = None)
Update the FPGA bitstream with a given bitstream, or to the newest version.
Also checks the bitstream file for plausibility and calculates the checksum.
- Parameters:
bitstreamPath (Optional[str]) – The path to the bitstream. If unspecified, upload newest packaged bitstream.
- Raises:
FileNotFoundError – If the bitstream file could not be found
Exception – If the bitstream file is of the wrong size
- updateFirmware(firmwarePath: str | None = None)
Update the microcontroller firmware with a given firmware, or to the newest version.
This also checks the firmware file for plausibility and calculates the checksum.
- Parameters:
firmwarePath (Optional[str]) – The path to the new firmware. If unspecified, upload newest packaged firmware.
- Raises:
FileNotFoundError – If the firmware file could not be found
Exception – If the firmware file is incompatible with the bootloader
Exception – If the firmware size is incompatible with the bootloader
- property vddio: float
Get the current IO voltage of the connected device.
- Returns:
The current IO voltage of the connected device
- Return type:
float
- writeFPGARegister(address: int, value: int)
Write directly to a register on the SmartWave’s FPGA.
- Parameters:
address (int) – The address to write to
value (int) – The value to write
- writeToDevice(data: bytes, acquireLock: bool = True)
Write bare data to the connected device.
- Parameters:
data (bytes) – the data to write
acquireLock (bool) – Whether to acquire lock for serial resource. Setting this to False may have adverse side effects.
- Raises:
Exception – If the serial connection is not active