# SpiBusDriver

Summary: [Methods](https://developer.android.com/reference/com/google/android/things/userdriver/pio/SpiBusDriver#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/com/google/android/things/userdriver/pio/SpiBusDriver#inhmethods) \| [\[Expand All\]](https://developer.android.com/reference/com/google/android/things/userdriver/pio/SpiBusDriver#)  

# SpiBusDriver


`
public


interface
SpiBusDriver
`


`


implements

`[Closeable](https://developer.android.com/reference/java/io/Closeable)`


`

|-------------------------------------------------------|
| com.google.android.things.userdriver.pio.SpiBusDriver |

<br />

*** ** * ** ***

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 methods                                                                                                                                                                                   ||
|----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` default void`                                                                                          | ` `[close](https://developer.android.com/reference/com/google/android/things/userdriver/pio/SpiBusDriver#close())`() ` Closes the bus.                                                                                                                                      |
| ` abstract `[SpiDevice](https://developer.android.com/reference/com/google/android/things/pio/SpiDevice) | ` `[createSpiDevice](https://developer.android.com/reference/com/google/android/things/userdriver/pio/SpiBusDriver#createSpiDevice(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` chipSelect) ` Creates an SPI device on the bus. |
| ` abstract `[String[]](https://developer.android.com/reference/java/lang/String)                         | ` `[getChipSelectNames](https://developer.android.com/reference/com/google/android/things/userdriver/pio/SpiBusDriver#getChipSelectNames())`() ` Returns the array of supported chip selects.                                                                               |
| ` default void`                                                                                          | ` `[open](https://developer.android.com/reference/com/google/android/things/userdriver/pio/SpiBusDriver#open())`() ` Opens the bus.                                                                                                                                         |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/com/google/android/things/userdriver/pio/SpiBusDriver#)From interface ` `[java.io.Closeable](https://developer.android.com/reference/java/io/Closeable)` ` |------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/io/Closeable#close())`() ` Closes this stream and releases any system resources associated with it. | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/com/google/android/things/userdriver/pio/SpiBusDriver#)From interface ` `[java.lang.AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable)` ` |------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[close](https://developer.android.com/reference/java/lang/AutoCloseable#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.

<br />

|                                                                Throws                                                                ||
|----------------------------------------------------------------------------|----------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/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.

<br />

|                                     Parameters                                      ||
|--------------|-----------------------------------------------------------------------|
| `chipSelect` | `String`: the name of the chip select to open the device with. <br /> |

|                                                                       Returns                                                                        ||
|----------------------------------------------------------------------------------------------|--------------------------------------------------------|
| [SpiDevice](https://developer.android.com/reference/com/google/android/things/pio/SpiDevice) | A new SpiDevice connected to the given address. <br /> |

|                                                                Throws                                                                 ||
|----------------------------------------------------------------------------|-----------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/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}.

<br />

|                                                Returns                                                 ||
|----------------------------------------------------------------------|----------------------------------|
| [String[]](https://developer.android.com/reference/java/lang/String) | An array of string names. <br /> |

### 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.

<br />

|                                                         Throws                                                          ||
|----------------------------------------------------------------------------|---------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | on I/O failure; the bus will remain closed. |

-

  ## Interfaces

  - [GpioDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/GpioDriver)
  - [I2cBusDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/I2cBusDriver)
  - [PwmDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PwmDriver)
  - [SpiBusDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/SpiBusDriver)
  - [UartDeviceDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/UartDeviceDriver)
-

  ## Classes

  - [PioDriverManager](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager)