Comment on page
SPI Functions
We highly encourage everyone to use our new Python package which is packed with features. This library is still supported, but is not recommended for new design.
This function sets the clock frequency of the SPI bus. The default clock frequency is 2MHz.
This function takes two parameters:
spiIndex
, which is always 0 on Binho Nova host adapter.clock
, which is the desired frequency from 500000 Hz to 12000000 Hz in 1000 Hz steps.
The host adapter will respond with '-OK' upon successful execution of the command.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
This function gets the currently configured clock frequency of the SPI bus.
This function takes one parameter:
spiIndex
, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'SPI0' followed by 'CLK' followed by the configured clock frequency in Hertz.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.getClockSPI(0)
This function sets the SPI bus bit order. The bit order can be configured to either LSB first or MSB first. The default bit order setting is MSB first.
This function takes two parameters:
spiIndex
, which is always 0 on Binho Nova host adapter.order
, which is the desired bit order, can be eitherLSBFIRST
orMSBFIRST
.
The host adapter will respond with '-OK' upon successful execution of the command.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
This function gets the currently configured SPI bus bit order.
This function takes one parameter:
spiIndex
, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'SPI0' followed by 'ORDER' followed by the currently configured bit order.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.getOrderSPI(0)
This function sets the SPI bus mode of operation. SPI Modes 0, 1, 2, or 3 are determined by CPOL and CPHA. It's possible to set the mode directly, or to configure CPOL and CPHA independently to determine the mode setting. The default mode is 0.
This function takes two parameters:
spiIndex
, which is always 0 on Binho Nova host adapter.mode
, which is the desired mode: 0, 1, 2, or 3.
The host adapter will respond with '-OK' upon successful execution of the command.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
This function gets the currently configured SPI bus mode.
This function takes one parameter:
spiIndex
, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'SPI0' followed by 'MODE' followed by the currently configured mode of operation.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.getModeSPI(0)
This function gets the current SPI bus Clock Polarity. Clock polarity indicates the idle condition of the clock signal. This is related to the SPI mode. It's possible to configure the CPOL setting directly by using this command, or indirectly by using the MODE command. The default value of CPOL is 0.
This function takes one parameter:
spiIndex
, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'SPI0' followed by 'CPOL' followed by the currently configured clock polarity value.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.getCpolSPI(0)
This function gets the current SPI bus Clock Phase. Clock Phase indicates when the data is valid in relation to the clock edges. This is related to the SPI mode. It's possible to configure the CPHA setting directly by using this command, or indirectly by using the MODE command. The default value of CPHA is 0.
This function takes one parameter:
spiIndex
, which is always 0 on Binho Nova host adapter.
The host adapter will respond with 'SPI0' followed by 'CPHA' followed by the currently configured clock phase value.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)
binhoDevice.getCphaSPI(0)
This function sets the number of bits per transmission. The SPI bus can be configured to either 8 or 16 bits per transfer. The default setting is 8 bits per transfer.
This function takes two parameters:
spiIndex
, which is always 0 on Binho Nova host adapter.bits
, which is the number of bits per transfer and can be either 8 or 16.
The host adapter will respond with '-OK' upon successful execution of the command.
from binhoHostAdapter import binhoHostAdapter
# Change this to match your COMPort
default_commport = "COM22"
binhoDevice = binhoHostAdapter.binhoHostAdapter(default_commport)
binhoDevice.setOperationMode(0, 'SPI')
binhoDevice.setClockSPI(0, 4000000)
binhoDevice.setOrderSPI(0, 'MSBFIRST')
binhoDevice.setModeSPI(0, 0)