Skip to content

Most visited

Recently visited

navigation

I2cBusDriver

I2cBusDriver

public abstract class I2cBusDriver
extends Object implements Closeable

java.lang.Object
   ↳ com.google.android.things.pio.I2cBusDriver


I2C user driver. An I2cBusDriver defines an entire I2C bus with multiple possible devices attached to it. Individual I2cDevice objects can be opened and closed on the bus independently.

Summary

Public constructors

I2cBusDriver()

Public methods

void close()

Closes the bus.

abstract I2cDevice createI2cDevice(int address)

Creates an I2C device on the bus.

void open()

Opens the bus.

Inherited methods

From class java.lang.Object
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Public constructors

I2cBusDriver

I2cBusDriver ()

Public methods

close

void close ()

Closes the bus. This will be called just after the last device is closed by its owner. Any resources that need to be cleaned up can be done so here. This method may throw IOException to indicate I/O failure, but the bus will still be considered closed and may attempt to be re-opened in the future.

Throws
IOException on I/O failure; the bus will still be considered closed.

createI2cDevice

I2cDevice createI2cDevice (int address)

Creates an I2C device on the bus. This will be called when ownership of a single I2C device is requested. The driver should create and return a new I2cDevice object. The driver manager will internally make sure that no other I2C device is opened at this address until the returned device is closed.

Parameters
address int: The I2C device address to open.
Returns
I2cDevice A new I2cDevice connected to the given address.
Throws
IOException on I/O failure; the I2C slave device will remain unowned.

open

void open ()

Opens the bus. This will be called just before the first device is requested on this bus. The driver may do any initialization needed to configure the bus for use here.

Throws
IOException on I/O failure; the bus will remain closed.
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.