Skip to content

Most visited

Recently visited

navigation

SpiBusDriver

SpiBusDriver

public abstract class SpiBusDriver
extends Object implements Closeable

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


SPI user driver. A SpiBusDriver defines an entire SPI bus with multiple possible devices attached to it. Individual SpiDevice objects can be opened and closed on the bus independently.

Summary

Public constructors

SpiBusDriver()

Public methods

void close()

Closes the bus.

abstract SpiDevice createSpiDevice(String chipSelect)

Creates an SPI device on the bus.

abstract String[] getChipSelectNames()

Returns the array of supported chip selects.

void open()

Opens the bus.

Inherited methods

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

Public constructors

SpiBusDriver

SpiBusDriver ()

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.

createSpiDevice

SpiDevice createSpiDevice (String chipSelect)

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

Parameters
chipSelect String: the name of the chip select to open the device with.
Returns
SpiDevice A new SpiDevice connected to the given address.
Throws
IOException on I/O failure; the SPI slave device will remain unowned.

getChipSelectNames

String[] getChipSelectNames ()

Returns the array of supported chip selects. Chip select names can be arbitrary strings. The resulting I/O names will be {bus_name}.{cs_name}.

Returns
String[] An array of string names.

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.