Using Properties on the SPI Object
Use the properties
function on the spi
object to
see its available properties.
The following code shows the output of properties
from the example,
Transmitting Data over the SPI Interface.
properties(S)
Properties for class instrument.interface.spi.aardvark.Spi: BitRate ClockPhase ClockPolarity ChipSelect Port BoardIndex VendorName BoardSerial ConnectionStatus TransferStatus
You can use these interface-specific properties with the spi
object.
Property | Description |
---|---|
BitRate | SPI clock speed. Must be a positive, nonzero value specified in
Hz. The default is
|
ClockPhase | SPI clock phase. Can be specified as
To change from the default:
|
ClockPolarity | SPI clock polarity. Can be specified as
To change from the default:
|
ChipSelect | SPI chip select line. The Aardvark adaptor uses
|
Port | Use to create
|
BoardSerial | Unique identifier of the SPI communication device. |
VendorName | Use to create
|
BoardIndex | Use to create
|
ConnectionStatus | Returns the connection status of the SPI object. Possible
values are |
TransferStatus | Returns the read/write operation status of the SPI object. Possible values:
|
The properties all have defaults, as indicated in the table. You do not need to set a
property unless you want to change it to a different value from the default. Aside from
the three properties required to construct the object – VendorName
,
BoardIndex
, and Port
– any other property is
set using dot-notation syntax:
<object_name>.<property_name> = <value>
Here is an example of using this syntax to change the BitRate
from the default of 1000 kHz to 500 kHz.
S.BitRate = 500000
Change the ClockPhase from the default of 'FirstEdge'
to
'SecondEdge'
.
S.ClockPhase = 'SecondEdge'
where S
is the name of the object used in the examples.
Note
To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB® command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.