PeripheralManager

public class PeripheralManager
extends Object

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


Lists and opens peripherals.

Listing available peripherals is available to all apps, but opening them requires the com.google.android.things.permission.USE_PERIPHERAL_IO permission.

Summary

Public methods

List<String> getGpioList()

Get the list of GPIO pins available.

List<String> getI2cBusList()

Get the list of I2C buses available.

static PeripheralManager getInstance()

Returns the PeripheralManager instance for this application.

List<String> getPwmList()

Get the list of PWM pins available.

List<String> getSpiBusList()

Get the list of SPI buses available.

List<String> getUartDeviceList()

Get the list of UART devices available.

Gpio openGpio(String name)

Open a GPIO pin.

I2cDevice openI2cDevice(String name, int address)

Open an I2C device.

Pwm openPwm(String name)

Open a PWM pin.

SpiDevice openSpiDevice(String name)

Open a SPI device.

UartDevice openUartDevice(String name)

Open an UART device.

Inherited methods

From class java.lang.Object

Public methods

getGpioList

List<String> getGpioList ()

Get the list of GPIO pins available. Refer to your board's documentation for the name to physical pin mapping. Not all the GPIO pins in the list will be free. Some may already be in use.

Returns
List<String>

getI2cBusList

List<String> getI2cBusList ()

Get the list of I2C buses available.

Returns
List<String>

getInstance

PeripheralManager getInstance ()

Returns the PeripheralManager instance for this application.

Returns
PeripheralManager The PeripheralManager instance.

getPwmList

List<String> getPwmList ()

Get the list of PWM pins available. Refer to your board's documentation for the name to physical pin mapping. Not all the PWM pins in the list will be free. Some may already be in use.

Returns
List<String>

getSpiBusList

List<String> getSpiBusList ()

Get the list of SPI buses available. Not all the SPI buses in the list will be free. Some may already be in use.

Returns
List<String>

getUartDeviceList

List<String> getUartDeviceList ()

Get the list of UART devices available.

Returns
List<String>

openGpio

Gpio openGpio (String name)

Open a GPIO pin. A GPIO pin can only be opened once at any given time on the system. To close and release the GPIO pin, you need to call close() explicitly.

Parameters
name String: Name of the GPIO pin as returned by getGpioList().

Returns
Gpio The GPIO object.

Throws
IOException Failed to open the named GPIO.

openI2cDevice

I2cDevice openI2cDevice (String name, 
                int address)

Open an I2C device. An I2C device can only be opened once at any given time on the system. To close and release the I2C device, you need to call close() explicitly.

Parameters
name String: Name of the I2C bus as returned by getI2cBusList().

address int: Address of the device as described on the device datasheet.

Returns
I2cDevice The I2cDevice object.

Throws
IOException Failed to open the named I2C device.

openPwm

Pwm openPwm (String name)

Open a PWM pin. A PWM pin can only be opened once at any given time on the system. To close and release the PWM pin, you need to call close() explicitly.

Parameters
name String: Name of the PWM pin as returned by getPwmList().

Returns
Pwm The PWM object.

Throws
IOException Failed to open the named PWM.

openSpiDevice

SpiDevice openSpiDevice (String name)

Open a SPI device. A SPI device can only be opened once at any given time on the system. To close and release the SPI device, you need to call close() explicitly.

Parameters
name String: Name of the SPI device as returned by getSpiBusList().

Returns
SpiDevice The SpiDevice object.

Throws
IOException Failed to open the named SPI device.

openUartDevice

UartDevice openUartDevice (String name)

Open an UART device. An UART device can only be opened once at any given time on the system. To close and release the UART device, you need to call close() explicitly.

Parameters
name String: Name of the UART bus as returned by getUartDeviceList().

Returns
UartDevice The UartDevice object.

Throws
IOException Failed to open the named UART.