I2C class

I2C wrapper functions for Linux userspace i2c-dev devices.

c-periphery I2C documentation.

Inheritance

Constructors

I2C(int busNum)
Opens the i2c-dev device at the specified path (e.g. "/dev/i2c-busNum").
I2C.isolate(String json)
Duplicates an existing I2C from a JSON string. This special constructor is used to transfer an existing I2C to an other isolate.

Properties

busNum int
final
hashCode int
The hash code for this object.
no setterinherited
isolate bool
final
path String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dispose() → void
Releases all internal native resources.
fromJson(String json) IsolateAPI
override
getErrno() int
Returns the libc errno of the last failure that occurred.
getHandle() int
Returns the address of the internal handle.
override
getI2Cfd() int
Returns the file descriptor (for the underlying i2c-dev device) of the I2C handle.
getI2Cinfo() String
Returns a string representation of the I2C handle.
isIsolate() bool
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readByte(int address) int
Reads a byte from the I2C device with the address. The optional register parameters bit order/width enables 16-bit register.
readByteReg(int address, int register, [BitOrder order = BitOrder.msbLast, RegisterWidth width = RegisterWidth.bits8]) int
Reads a byte from register of the I2C device with the address.
readBytes(int address, int len) List<int>
Reads len bytes from the I2C device with the address.
readBytesReg(int address, int register, int len, [BitOrder order = BitOrder.msbLast, RegisterWidth width = RegisterWidth.bits8]) List<int>
Reads len bytes from register of the I2C device with the address.
readWord(int address, [BitOrder order = BitOrder.msbLast, RegisterWidth width = RegisterWidth.bits8]) int
Reads a word from the I2C device with the address and the bit order].
readWordReg(int address, int register, [BitOrder order = BitOrder.msbLast, RegisterWidth width = RegisterWidth.bits8]) int
Reads a word from register of the I2C device with the address with the bit order.
setHandle(int handle) → void
Set the address of the internal handle.
override
toJson() String
Converts a I2C to a JSON string. See constructor isolate for details.
override
toString() String
A string representation of this object.
inherited
transfer(List<I2Cmsg> data) NativeI2CmsgHelper
Transfers a list of I2Cmsg.
writeByte(int address, int byteValue) → void
Writes a byteValue to the I2C device with the address.
writeByteReg(int address, int register, int byteValue, [BitOrder order = BitOrder.msbLast, RegisterWidth width = RegisterWidth.bits8]) → void
Writes a byteValue to the register of the I2C device with the address. The optional register parameters bit order/width enables 16-bit register.
writeBytes(int address, List<int> byteData) → void
Writes byteData to the I2C device with the address.
writeBytesReg(int address, int register, List<int> byteData, [BitOrder order = BitOrder.msbLast, RegisterWidth width = RegisterWidth.bits8]) → void
Writes byteData to the register of the I2C device with the address The optional register parameters bit order/width enables 16-bit registers.
writeUint8Reg(int address, int register, Uint8List byteData, [BitOrder order = BitOrder.msbLast, RegisterWidth width = RegisterWidth.bits8]) → void
writeWord(int address, int wordValue, [BitOrder order = BitOrder.msbLast]) → void
Writes a wordValue to the I2C device with the address and the bit order.
writeWordReg(int address, int register, int wordValue, [BitOrder order = BitOrder.msbLast, RegisterWidth width = RegisterWidth.bits8]) → void
Writes a wordValue to the register of the I2C device with the address and the bit order. The optional register parameters bit width enables 16-bit register.

Operators

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

Static Methods

getI2CerrorCode(int value) I2CerrorCode
Converts the native error code value to I2CerrorCode.
i2cMsgFlags2Int(I2CmsgFlags flag) int
Converts I2CmsgFlags to the native bit mask value.