Stay organized with collections
Save and categorize content based on your preferences.
I2cBusDriver
public
interface
I2cBusDriver
implements
Closeable
com.google.android.things.userdriver.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 methods |
default
void
|
close()
Closes the bus.
|
abstract
I2cDevice
|
createI2cDevice(int address)
Creates an I2C device on the bus.
|
default
void
|
open()
Opens the bus.
|
Inherited methods |
From
interface
java.io.Closeable
abstract
void
|
close()
Closes this stream and releases any system resources associated
with it.
|
|
From
interface
java.lang.AutoCloseable
abstract
void
|
close()
Closes this resource, relinquishing any underlying resources.
|
|
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.
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# I2cBusDriver\n\nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \\| [\\[Expand All\\]](#) \n\nI2cBusDriver\n============\n\n\n`\npublic\n\n\ninterface\nI2cBusDriver\n`\n\n\n`\n\n\nimplements\n\n`[Closeable](/reference/java/io/Closeable)`\n\n\n`\n\n|-------------------------------------------------------|\n| com.google.android.things.userdriver.pio.I2cBusDriver |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nI2C user driver.\n\nAn I2cBusDriver defines an entire I2C bus with multiple possible devices attached to it.\nIndividual I2cDevice objects can be opened and closed on the bus independently.\n\nSummary\n-------\n\n| ### Public methods ||\n|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` default void` | ` `[close](/reference/com/google/android/things/userdriver/pio/I2cBusDriver#close())`() ` Closes the bus. |\n| ` abstract `[I2cDevice](/reference/com/google/android/things/pio/I2cDevice) | ` `[createI2cDevice](/reference/com/google/android/things/userdriver/pio/I2cBusDriver#createI2cDevice(int))`(int address) ` Creates an I2C device on the bus. |\n| ` default void` | ` `[open](/reference/com/google/android/things/userdriver/pio/I2cBusDriver#open())`() ` Opens the bus. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[java.io.Closeable](/reference/java/io/Closeable)` ` |------------------|--------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](/reference/java/io/Closeable#close())`() ` Closes this stream and releases any system resources associated with it. | ||\n| From interface ` `[java.lang.AutoCloseable](/reference/java/lang/AutoCloseable)` ` |------------------|---------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](/reference/java/lang/AutoCloseable#close())`() ` Closes this resource, relinquishing any underlying resources. | ||\n\nPublic methods\n--------------\n\n### close\n\n```\nvoid close ()\n```\n\nCloses the bus.\n\nThis will be called just after the last device is closed by its owner. Any resources\nthat need to be cleaned up can be done so here.\n\nThis method may throw IOException to indicate I/O failure, but the bus will still be\nconsidered closed and may attempt to be re-opened in the future.\n\n\u003cbr /\u003e\n\n| Throws ||\n|-----------------------------------------------|----------------------------------------------------------|\n| [IOException](/reference/java/io/IOException) | on I/O failure; the bus will still be considered closed. |\n\n### createI2cDevice\n\n```\nI2cDevice createI2cDevice (int address)\n```\n\nCreates an I2C device on the bus.\n\nThis will be called when ownership of a single I2C device is requested. The driver should\ncreate and return a new I2cDevice object.\n\nThe driver manager will internally make sure that no other I2C device is opened at this\naddress until the returned device is closed.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|-----------------------------------------------|\n| `address` | `int`: The I2C device address to open. \u003cbr /\u003e |\n\n| Returns ||\n|-----------------------------------------------------------------|--------------------------------------------------------|\n| [I2cDevice](/reference/com/google/android/things/pio/I2cDevice) | A new I2cDevice connected to the given address. \u003cbr /\u003e |\n\n| Throws ||\n|-----------------------------------------------|-----------------------------------------------------------|\n| [IOException](/reference/java/io/IOException) | on I/O failure; the I2C slave device will remain unowned. |\n\n### open\n\n```\nvoid open ()\n```\n\nOpens the bus.\n\nThis will be called just before the first device is requested on this bus. The driver\nmay do any initialization needed to configure the bus for use here.\n\n\u003cbr /\u003e\n\n| Throws ||\n|-----------------------------------------------|---------------------------------------------|\n| [IOException](/reference/java/io/IOException) | on I/O failure; the bus will remain closed. |\n\n-\n\n Interfaces\n ----------\n\n - [GpioDriver](/reference/com/google/android/things/userdriver/pio/GpioDriver)\n - [I2cBusDriver](/reference/com/google/android/things/userdriver/pio/I2cBusDriver)\n - [PwmDriver](/reference/com/google/android/things/userdriver/pio/PwmDriver)\n - [SpiBusDriver](/reference/com/google/android/things/userdriver/pio/SpiBusDriver)\n - [UartDeviceDriver](/reference/com/google/android/things/userdriver/pio/UartDeviceDriver)\n-\n\n Classes\n -------\n\n - [PioDriverManager](/reference/com/google/android/things/userdriver/pio/PioDriverManager)"]]