res =
fopen (obj) (dummy)
¶Opens SPI connection obj
This currently is a dummy function to improve compatibility to MATLAB
data =
fread (obj)
¶data =
fread (obj, size)
¶data =
fread (obj, size, precision)
¶[data,count] =
fread (obj, ...)
¶[data,count,errmsg] =
fread (obj, ...)
¶Reads data from a SPI instrument
obj is a SPI object.
size Number of values to read. (Default: 10).
precision precision of data.
data data values.
count number of values read.
errmsg read operation error message.
struct =
get (spi)
¶field =
get (spi, property)
¶Get the properties of spi object.
spi - instance of octave_spi class.
property - name of property.
Name for the spi socket.
The bitrate for the spi object.
The clock polarity for the spi object of ’idlehigh’ or ’idlelow’.
The clock phase for the spi object of ’firstedge’ or ’secondedge’.
The device port name.
The device status of ’open’ or ’closed’
When property was specified, return the value of that property.
otherwise return the values of all properties as a structure.
See also: @octave_spi/set.
set
(obj, property,value)
¶set
(obj, property,value,…)
¶Set the properties of spi object.
obj - instance of octave_spi class.
property - name of property.
If property is a cell so must be value, it sets the values of all matching properties.
The function also accepts property-value pairs.
Set the name for the spi socket.
Set the bitrate for the spi object.
Set the clock polarity for the spi object of ’idlehigh’ or ’idlelow’.
Set the clock phase for the spi object of ’firstedge’ or ’secondedge’.
None
See also: @octave_spi/get.
numbytes =
fwrite (obj, data)
¶Writes data to SPI instrument
obj is a SPI object.
data data to write.
returns number of bytes written.
data =
writeAndRead (obj, wrdata)
¶Writes and reads data from SPI instrument
obj is a SPI object.
wrdata Data to write.
data data values read.
spi =
spi ([port_path])
¶spi =
spi ([port_path], [propname, propvalue])
¶Open a spi interface.
port_path - the interface device port/path of type String. If omitted defaults to
’/dev/spi-0’.
propname,propvalue - property name/value pairs.
Known input properties:
Name of the object
Numeric bitrate value
Clock polarity: idlehigh or idlelow.
Clock phase value: firstedge or secondedge
spi - An instance of octave_spi class.
The spi object has the following properties:
Name of the object
Open or closed status of object (readonly).
Numeric bitrate value
Clock polarity: idlehigh or idlelow.
Clock phase value: firstedge or secondedge
The interface driver port (readonly)
(spi)
¶Close the interface and release a file descriptor.
spi - instance of octave_spi class.
None
[data, count] =
spi_read (spi, n)
¶Read from spi slave device.
spi - instance of octave_spi class.
n - number of bytes to attempt to read of type Integer.
The spi_read() shall return number of bytes successfully read in count as Integer and the bytes themselves in data as uint8 array.
n =
spi_write (spi, data)
¶Write data to a spi slave device.
spi - instance of octave_spi class.
data - data, of type uint8, to be written to the slave device.
Upon successful completion, spi_write() shall return the number of bytes written as the result n.
rddata =
spi_writeAndRead (spi, wrdata)
¶Write data to a spi slave device and then read same number of values.
spi - instance of octave_spi class.
wrdata - data, of type uint8, to be written to the slave device.
Upon successful completion, spi_writeAndRead() shall return the bytes read.