Struct i2c_linux::I2c

source ·
pub struct I2c<I> { /* private fields */ }
Expand description

A safe wrapper around an I2C device.

Implementations

Open an I2C device

Creates a new I2C handle with the given file descriptor

Consumes the I2C handle to return the inner file descriptor.

Borrows the inner file descriptor.

Mutably borrows the inner file descriptor.

Sets the number of times to retry communication before failing.

Sets a timeout for I2C operations

Set the slave address to communicate with.

Enable or disable SMBus Packet Error Checking.

Retrieve the capabilities of the I2C device. These should be checked before attempting to use certain SMBus commands or I2C flags.

i2c_transfer capabilities of the I2C device. These should be checked before attempting to use any of the protocol mangling flags.

Executes a queue of I2C transfers, separated by repeat START conditions. Data buffers are truncated to the actual read length on completion.

See the I2C_RDWR ioctl for more information.

Sends a single bit to the device, in the place of the Rd/Wr address bit.

Reads a single byte from a device without specifying a register.

Some devices are so simple that this interface is enough; for others, it is a shorthand if you want to read the same register as in the previous SMBus command.

Sends a single byte to a device.

Reads a single byte from a device from the designated register.

Writes a single byte to a device to the designated register.

Reads a 16-bit word from the device register.

Writes a 16-bit word to the device register.

Selects a device register, sends a 16-bit word to it, and read 16-bits of data in return.

Read up to 32 bytes from the designated device register.

Returns the amount of data read.

Write up to 32 bytes to the designated device register.

Sends up to 31 bytes of data to the designated device register, and reads up to 31 bytes in return.

This was introduced in SMBus 2.0

Reads a block of bytes from the designated device register.

Unlike smbus_read_block_data this does not receive a data length. This is limited to 32 bytes due to the use of the Linux SMBus interface. Use i2c_transfer() if more data is needed. write()+read() may also be an option, though will produce an I2C STOP condition between the transfers, which may be undesirable.

Writes a block of bytes from the designated device register.

Unlike smbus_write_block_data this does not transfer the data length. This is limited to 32 bytes due to the use of the Linux SMBus interface. Use i2c_transfer() or write() instead if more data is needed.

Trait Implementations

Sets the current slave to address. Read more
Extracts the raw file descriptor. Read more
Reads a block of bytes from the designated device register. Read more
Writes a block of bytes to the designated device register. Read more
Specifies the flags that this implementation supports.
Executes a queue of I2C transfers, separated by repeated START conditions. Data buffers are truncated to the actual read length on completion. Read more
Constructs a new instance of Self from the given raw file descriptor. Read more
Consumes this object, returning the raw underlying file descriptor. Read more
The error type returned by I2C operations.
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
Like read, except that it reads into a slice of buffers. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
Read all bytes until EOF in this source, placing them into buf. Read more
Read all bytes until EOF in this source, appending them to buf. Read more
Read the exact number of bytes required to fill buf. Read more
🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
🔬This is a nightly-only experimental API. (read_buf)
Read the exact number of bytes required to fill cursor. Read more
Creates a “by reference” adaptor for this instance of Read. Read more
Transforms this Read instance to an Iterator over its bytes. Read more
Creates an adapter which will chain this stream with another. Read more
Creates an adapter which will read at most limit bytes from it. Read more
Sends a single bit to the device, in the place of the rd/wr address bit.
Reads a single byte from a device without specifying a register.
Sends a single byte to the device
Reads a byte from the designated register.
Writes a byte to the designated register.
Reads a 16-bit word from the designated register.
Writes a 16-bit word to the designated register.
Writes a 16-bit word to the specified register, then reads a 16-bit word in response. Read more
Reads up to 32 bytes from the designated device register. Read more
Writes up to 32 bytes to the designated device register.
Sends up to 31 bytes of data to the designated register, and reads up to 31 bytes in return. Read more
Enables or disables SMBus Packet Error Checking
Write a buffer into this writer, returning how many bytes were written. Read more
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
Like write, except that it writes from a slice of buffers. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
Attempts to write an entire buffer into this writer. Read more
🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
Writes a formatted string into this writer, returning any error encountered. Read more
Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Reads an unsigned 8 bit integer from the underlying reader. Read more
Reads a signed 8 bit integer from the underlying reader. Read more
Reads an unsigned 16 bit integer from the underlying reader. Read more
Reads a signed 16 bit integer from the underlying reader. Read more
Reads an unsigned 24 bit integer from the underlying reader. Read more
Reads a signed 24 bit integer from the underlying reader. Read more
Reads an unsigned 32 bit integer from the underlying reader. Read more
Reads a signed 32 bit integer from the underlying reader. Read more
Reads an unsigned 48 bit integer from the underlying reader. Read more
Reads a signed 48 bit integer from the underlying reader. Read more
Reads an unsigned 64 bit integer from the underlying reader. Read more
Reads a signed 64 bit integer from the underlying reader. Read more
Reads an unsigned 128 bit integer from the underlying reader. Read more
Reads a signed 128 bit integer from the underlying reader. Read more
Reads an unsigned n-bytes integer from the underlying reader. Read more
Reads a signed n-bytes integer from the underlying reader. Read more
Reads an unsigned n-bytes integer from the underlying reader.
Reads a signed n-bytes integer from the underlying reader.
Reads a IEEE754 single-precision (4 bytes) floating point number from the underlying reader. Read more
Reads a IEEE754 double-precision (8 bytes) floating point number from the underlying reader. Read more
Reads a sequence of unsigned 16 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 32 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 64 bit integers from the underlying reader. Read more
Reads a sequence of unsigned 128 bit integers from the underlying reader. Read more
Reads a sequence of signed 8 bit integers from the underlying reader. Read more
Reads a sequence of signed 16 bit integers from the underlying reader. Read more
Reads a sequence of signed 32 bit integers from the underlying reader. Read more
Reads a sequence of signed 64 bit integers from the underlying reader. Read more
Reads a sequence of signed 128 bit integers from the underlying reader. Read more
Reads a sequence of IEEE754 single-precision (4 bytes) floating point numbers from the underlying reader. Read more
👎Deprecated since 1.2.0: please use read_f32_into instead
DEPRECATED. Read more
Reads a sequence of IEEE754 double-precision (8 bytes) floating point numbers from the underlying reader. Read more
👎Deprecated since 1.2.0: please use read_f64_into instead
DEPRECATED. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Writes an unsigned 8 bit integer to the underlying writer. Read more
Writes a signed 8 bit integer to the underlying writer. Read more
Writes an unsigned 16 bit integer to the underlying writer. Read more
Writes a signed 16 bit integer to the underlying writer. Read more
Writes an unsigned 24 bit integer to the underlying writer. Read more
Writes a signed 24 bit integer to the underlying writer. Read more
Writes an unsigned 32 bit integer to the underlying writer. Read more
Writes a signed 32 bit integer to the underlying writer. Read more
Writes an unsigned 48 bit integer to the underlying writer. Read more
Writes a signed 48 bit integer to the underlying writer. Read more
Writes an unsigned 64 bit integer to the underlying writer. Read more
Writes a signed 64 bit integer to the underlying writer. Read more
Writes an unsigned 128 bit integer to the underlying writer.
Writes a signed 128 bit integer to the underlying writer.
Writes an unsigned n-bytes integer to the underlying writer. Read more
Writes a signed n-bytes integer to the underlying writer. Read more
Writes an unsigned n-bytes integer to the underlying writer. Read more
Writes a signed n-bytes integer to the underlying writer. Read more
Writes a IEEE754 single-precision (4 bytes) floating point number to the underlying writer. Read more
Writes a IEEE754 double-precision (8 bytes) floating point number to the underlying writer. Read more