# PioDriverManager

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

# PioDriverManager

`
public


class
PioDriverManager
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-----------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | com.google.android.things.userdriver.pio.PioDriverManager |

<br />

*** ** * ** ***

Manager for PIO userspace drivers. Registered drivers are individually synchronized to guarantee that no calls will be made before open() or after close(), and no calls will be made concurrently on the same driver. Driver registration and unregistration is also thread-safe and may be done while a driver is in use. If a driver is unregistered while in use, subsequent calls will raise an exception.

## Summary

|                                                                                                                                                                                                                                                                                                           ### Public methods                                                                                                                                                                                                                                                                                                            ||
|---------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` static `[PioDriverManager](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager) | ` `[getInstance](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#getInstance())`() ` Returns the[PioDriverManager](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager)instance for this application.                                                                                                                                                                                                  |
| ` void`                                                                                                                         | ` `[registerGpioDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#registerGpioDriver(java.lang.String, com.google.android.things.userdriver.pio.GpioDriver))`(`[String](https://developer.android.com/reference/java/lang/String)` name, `[GpioDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/GpioDriver)` driver) ` Registers a new GPIO driver with the PIO manager.                               |
| ` void`                                                                                                                         | ` `[registerI2cBusDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#registerI2cBusDriver(java.lang.String, com.google.android.things.userdriver.pio.I2cBusDriver))`(`[String](https://developer.android.com/reference/java/lang/String)` name, `[I2cBusDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/I2cBusDriver)` driver) ` Registers a new I2C driver with the PIO manager.                      |
| ` void`                                                                                                                         | ` `[registerPwmDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#registerPwmDriver(java.lang.String, com.google.android.things.userdriver.pio.PwmDriver))`(`[String](https://developer.android.com/reference/java/lang/String)` name, `[PwmDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PwmDriver)` driver) ` Registers a new PWM driver with the PIO manager.                                     |
| ` void`                                                                                                                         | ` `[registerSpiBusDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#registerSpiBusDriver(java.lang.String, com.google.android.things.userdriver.pio.SpiBusDriver))`(`[String](https://developer.android.com/reference/java/lang/String)` busName, `[SpiBusDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/SpiBusDriver)` driver) ` Registers a new SPI driver with the PIO manager.                   |
| ` void`                                                                                                                         | ` `[registerUartDeviceDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#registerUartDeviceDriver(java.lang.String, com.google.android.things.userdriver.pio.UartDeviceDriver))`(`[String](https://developer.android.com/reference/java/lang/String)` name, `[UartDeviceDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/UartDeviceDriver)` driver) ` Registers a new UART driver with the PIO manager. |
| ` void`                                                                                                                         | ` `[unregisterGpioDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#unregisterGpioDriver(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Unregisters an existing GPIO driver from the PIO manager.                                                                                                                                                                                            |
| ` void`                                                                                                                         | ` `[unregisterI2cBusDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#unregisterI2cBusDriver(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Unregisters an existing I2C driver from the PIO manager.                                                                                                                                                                                         |
| ` void`                                                                                                                         | ` `[unregisterPwmDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#unregisterPwmDriver(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Unregisters an existing PWM driver from the PIO manager.                                                                                                                                                                                               |
| ` void`                                                                                                                         | ` `[unregisterSpiBusDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#unregisterSpiBusDriver(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` busName) ` Unregisters an existing SPI driver from the PIO manager.                                                                                                                                                                                      |
| ` void`                                                                                                                         | ` `[unregisterUartDeviceDriver](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#unregisterUartDeviceDriver(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Unregisters an existing UART driver from the PIO manager.                                                                                                                                                                                |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                                                                                                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                                                                                                                                                                                                                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                                                                                                                                                                                                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                                                                                                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                                                                                                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                                                                                                                                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                                                                                                                                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                                                                                                                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long, int))`(long millis, int nanos) ` Causes the current thread to wait until another thread invokes the[notify()](https://developer.android.com/reference/java/lang/Object.html#notify())method or the[notifyAll()](https://developer.android.com/reference/java/lang/Object.html#notifyAll())method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long millis) ` Causes the current thread to wait until either another thread invokes the[notify()](https://developer.android.com/reference/java/lang/Object.html#notify())method or the[notifyAll()](https://developer.android.com/reference/java/lang/Object.html#notifyAll())method for this object, or a specified amount of time has elapsed.                                                                 | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until another thread invokes the[notify()](https://developer.android.com/reference/java/lang/Object.html#notify())method or the[notifyAll()](https://developer.android.com/reference/java/lang/Object.html#notifyAll())method for this object.                                                                                                                                  | ||

## Public methods

### getInstance

```
PioDriverManager getInstance ()
```

Returns the[PioDriverManager](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager)instance for this application.

<br />

|                                                                           Returns                                                                            ||
|-----------------------------------------------------------------------------------------------------------------------|---------------------------------------|
| [PioDriverManager](https://developer.android.com/reference/com/google/android/things/userdriver/pio/PioDriverManager) | The PioDriverManager instance. <br /> |

|                                                                      Throws                                                                      ||
|--------------------------------------------------------------------------------------------------|------------------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if the underlying system service is not ready. |

### registerGpioDriver

```
void registerGpioDriver (String name, 
                GpioDriver driver)
```

Registers a new GPIO driver with the PIO manager.

<br />

|                 Parameters                  ||
|----------|-----------------------------------|
| `name`   | `String`: GPIO name. <br />       |
| `driver` | `GpioDriver`: GPIO driver. <br /> |

|                                                   Throws                                                   ||
|----------------------------------------------------------------------------|--------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | failed to register the driver. |

### registerI2cBusDriver

```
void registerI2cBusDriver (String name, 
                I2cBusDriver driver)
```

Registers a new I2C driver with the PIO manager.

<br />

|                      Parameters                       ||
|----------|---------------------------------------------|
| `name`   | `String`: I2C bus name. <br />              |
| `driver` | `I2cBusDriver`: I2cBusDriver driver. <br /> |

|                                                   Throws                                                   ||
|----------------------------------------------------------------------------|--------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | failed to register the driver. |

### registerPwmDriver

```
void registerPwmDriver (String name, 
                PwmDriver driver)
```

Registers a new PWM driver with the PIO manager.

<br />

|                Parameters                 ||
|----------|---------------------------------|
| `name`   | `String`: PWM name. <br />      |
| `driver` | `PwmDriver`: PWM driver. <br /> |

|                                                   Throws                                                   ||
|----------------------------------------------------------------------------|--------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | failed to register the driver. |

### registerSpiBusDriver

```
void registerSpiBusDriver (String busName, 
                SpiBusDriver driver)
```

Registers a new SPI driver with the PIO manager. The SPI bus name may match an existing SPI bus in order to add more chip selects, but a single PioDriverManager cannot register multiple drivers with the same bus name.

<br />

|                       Parameters                       ||
|-----------|---------------------------------------------|
| `busName` | `String`: SPI bus name. <br />              |
| `driver`  | `SpiBusDriver`: SpiBusDriver driver. <br /> |

|                                                   Throws                                                   ||
|----------------------------------------------------------------------------|--------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | failed to register the driver. |

### registerUartDeviceDriver

```
void registerUartDeviceDriver (String name, 
                UartDeviceDriver driver)
```

Registers a new UART driver with the PIO manager.

<br />

|                    Parameters                     ||
|----------|-----------------------------------------|
| `name`   | `String`: UART name. <br />             |
| `driver` | `UartDeviceDriver`: UART driver. <br /> |

|                                                   Throws                                                   ||
|----------------------------------------------------------------------------|--------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | failed to register the driver. |

### unregisterGpioDriver

```
void unregisterGpioDriver (String name)
```

Unregisters an existing GPIO driver from the PIO manager. If the named driver is open it will be closed and any subsequent usage by the owner will throw IOException. If the named driver doesn't exist this method has no effect.

<br />

|             Parameters              ||
|--------|-----------------------------|
| `name` | `String`: GPIO name. <br /> |

|                                                                     Throws                                                                     ||
|----------------------------------------------------------------------------|--------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | error while closing the driver; driver will still be unregistered. |

### unregisterI2cBusDriver

```
void unregisterI2cBusDriver (String name)
```

Unregisters an existing I2C driver from the PIO manager. If the named driver is open it will be closed and any subsequent usage by the owner will throw IOException. If the named driver doesn't exist this method has no effect.

<br />

|               Parameters               ||
|--------|--------------------------------|
| `name` | `String`: I2C bus name. <br /> |

|                                                                     Throws                                                                     ||
|----------------------------------------------------------------------------|--------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | error while closing the driver; driver will still be unregistered. |

### unregisterPwmDriver

```
void unregisterPwmDriver (String name)
```

Unregisters an existing PWM driver from the PIO manager. If the named driver is open it will be closed and any subsequent usage by the owner will throw IOException. If the named driver doesn't exist this method has no effect.

<br />

|             Parameters             ||
|--------|----------------------------|
| `name` | `String`: PWM name. <br /> |

|                                                                     Throws                                                                     ||
|----------------------------------------------------------------------------|--------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | error while closing the driver; driver will still be unregistered. |

### unregisterSpiBusDriver

```
void unregisterSpiBusDriver (String busName)
```

Unregisters an existing SPI driver from the PIO manager. If any devices on the named driver are open they will be closed and any subsequent usage by the owner will throw IOException. If the named driver doesn't exist this method has no effect.

<br />

|                Parameters                 ||
|-----------|--------------------------------|
| `busName` | `String`: SPI bus name. <br /> |

|                                                                     Throws                                                                     ||
|----------------------------------------------------------------------------|--------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | error while closing the driver; driver will still be unregistered. |

### unregisterUartDeviceDriver

```
void unregisterUartDeviceDriver (String name)
```

Unregisters an existing UART driver from the PIO manager. If the named driver is open it will be closed and any subsequent usage by the owner will throw IOException. If the named driver doesn't exist this method has no effect.

<br />

|             Parameters              ||
|--------|-----------------------------|
| `name` | `String`: UART name. <br /> |

|                                                                     Throws                                                                     ||
|----------------------------------------------------------------------------|--------------------------------------------------------------------|
| [IOException](https://developer.android.com/reference/java/io/IOException) | error while closing the driver; driver will still be unregistered. |

-

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