PioDriverManager

public class PioDriverManager
extends Object

java.lang.Object
   ↳ com.google.android.things.userdriver.pio.PioDriverManager


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 getInstance()

Returns the PioDriverManager instance for this application.

void registerGpioDriver(String name, GpioDriver driver)

Registers a new GPIO driver with the PIO manager.

void registerI2cBusDriver(String name, I2cBusDriver driver)

Registers a new I2C driver with the PIO manager.

void registerPwmDriver(String name, PwmDriver driver)

Registers a new PWM driver with the PIO manager.

void registerSpiBusDriver(String busName, SpiBusDriver driver)

Registers a new SPI driver with the PIO manager.

void registerUartDeviceDriver(String name, UartDeviceDriver driver)

Registers a new UART driver with the PIO manager.

void unregisterGpioDriver(String name)

Unregisters an existing GPIO driver from the PIO manager.

void unregisterI2cBusDriver(String name)

Unregisters an existing I2C driver from the PIO manager.

void unregisterPwmDriver(String name)

Unregisters an existing PWM driver from the PIO manager.

void unregisterSpiBusDriver(String busName)

Unregisters an existing SPI driver from the PIO manager.

void unregisterUartDeviceDriver(String name)

Unregisters an existing UART driver from the PIO manager.

Inherited methods

From class java.lang.Object

Public methods

getInstance

PioDriverManager getInstance ()

Returns the PioDriverManager instance for this application.

Returns
PioDriverManager The PioDriverManager instance.

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

Parameters
name String: GPIO name.

driver GpioDriver: GPIO driver.

Throws
IOException failed to register the driver.

registerI2cBusDriver

void registerI2cBusDriver (String name, 
                I2cBusDriver driver)

Registers a new I2C driver with the PIO manager.

Parameters
name String: I2C bus name.

driver I2cBusDriver: I2cBusDriver driver.

Throws
IOException failed to register the driver.

registerPwmDriver

void registerPwmDriver (String name, 
                PwmDriver driver)

Registers a new PWM driver with the PIO manager.

Parameters
name String: PWM name.

driver PwmDriver: PWM driver.

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

Parameters
busName String: SPI bus name.

driver SpiBusDriver: SpiBusDriver driver.

Throws
IOException failed to register the driver.

registerUartDeviceDriver

void registerUartDeviceDriver (String name, 
                UartDeviceDriver driver)

Registers a new UART driver with the PIO manager.

Parameters
name String: UART name.

driver UartDeviceDriver: UART driver.

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

Parameters
name String: GPIO name.

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

Parameters
name String: I2C bus name.

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

Parameters
name String: PWM name.

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

Parameters
busName String: SPI bus name.

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

Parameters
name String: UART name.

Throws
IOException error while closing the driver; driver will still be unregistered.