SPI class

SPI wrapper functions for Linux userspace spidev devices.

c-periphery SPI documentation.

Constructors

SPI(int bus, int chip, SPImode mode, int maxSpeed)
Opens the SPI device at the path ("/dev/spidevbus.chip"), with the specified SPI mode, specified maxSpeed in hertz, and the defaults of MSB_FIRST bit order, and 8 bits per word.
SPI.isolate(String json)
Duplicates an existing SPI from a JSON string. This special constructor is used to transfer an existing SPI to an other isolate.
SPI.openAdvanced(int bus, int chip, SPImode mode, int maxSpeed, BitOrder bitOrder, int bitsPerWord, int extraFlags)
Opens the SPI device at the specified path ("/dev/spidevbus.chip"), with the specified SPI mode, maxSpeed in hertz, bitOrder, bitsPerWord, and extraFlags.
SPI.openAdvanced2(int bus, int chip, String path, SPImode mode, int maxSpeed, BitOrder bitOrder, int bitsPerWord, int extraFlags)
Opens the SPI device at the specified path, with the specified SPI mode, maxSpeed in hertz, bitOrder, bitsPerWord, and extraFlags. This open function is the same as SPI.openAdvanced, except that extra_flags can be 32-bits.

Properties

bitOrder BitOrder
SPI bit order
final
bitsPerWord int
SPI transfer word size
final
bus int
SPI bus number: /dev/spidevbus.chip
final
chip int
SPI chip number: /dev/spidevbus.chip
final
extraFlags int
SPI extra flags
final
hashCode int
The hash code for this object.
no setterinherited
maxSpeed int
SPI bus speed
final
mode SPImode
SPI mode
final
path String
SPI device path: /dev/spidevbus.chip
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Releases all interal native resoures.
getErrno() int
Returns the libc errno of the last failure that occurred.
getHandle() int
Returns the address of the internal handle.
getSPIbitOrder() BitOrder
Returns the BitOrder.
getSPIbitsPerWord() int
Returns bits per word.
getSPIextraFlags() int
Returns the 8-bit extra flags mask.
getSPIextraFlags32() int
Returns the 32-bit extra flags mask.
getSPIfd() int
Returns the file descriptor (for the underlying spidev device) of the SPI handle.
getSPIinfo() String
Returns a string representation of the spi handle.
getSPImaxSpeed() int
Returns the max speed of the SPI bus.
getSPImode() SPImode
Returns the SPImode.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setSPIbitOrder(BitOrder bitOrder) → void
Sets the bitOrder.
setSPIbitsPerWord(int value) → void
Sets the bits per word.
setSPIextraFlags(int value) → void
Sets the 8-bit extra flags mask.
setSPIextraFlags32(int value) → void
Sets the 32-bit extra flags mask.
setSPImaxSpeed(int maxSpeed) → void
Sets the maxSpeed of the SPI bus.
setSPImode(SPImode mode) → void
Sets the SPImode.
toJson() String
Converts a SPI to a JSON string. See constructor isolate for detials.
toString() String
A string representation of this object.
inherited
transfer(List<int> data, bool reuseBuffer) List<int>
Shifts out data, while shifting in the data to the result buffer. If reuseBuffer is true, data will be used for the result buffer, for false a new buffer will be created.
transferInt8(Pointer<Uint8> data, bool reuseBuffer, int len) Pointer<Uint8>
Shifts out len word counts of the data budder, while shifting in the result buffer. If reuseBuffer is true, data will be used the result buffer, for false a new buffer will be created.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

getSPIerrorCode(int value) → SPIerrorCode
Converts the native error code value to GPIOerrorCode.