Skip to content

Most visited

Recently visited

navigation

PeripheralManagerService

PeripheralManagerService

public class PeripheralManagerService
extends Object

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


Lists and opens peripherals.

Summary

Public constructors

PeripheralManagerService()

Create a PeripheralManagerService object.

Public methods

List<String> getGpioList()

Get the list of GPIO pins available.

List<String> getI2cBusList()

Get the list of I2C buses available.

List<String> getI2sDeviceList()

Get the list of I2s devices available.

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.

I2sDevice openI2sDevice(String name, AudioFormat format)

This method is deprecated. Use openI2sDevice(String, AudioFormat, int) instead.

I2sDevice openI2sDevice(String name, AudioFormat format, int flags)

Open an I2s device.

I2sDevice openI2sDevice(String name, int encoding, int channels, int rate, int flags)

Open an I2s device.

I2sDevice openI2sDevice(String name, int encoding, int channels, int rate)

This method is deprecated. Use openI2sDevice(String, int, int, int, int) instead.

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 constructors

PeripheralManagerService

PeripheralManagerService ()

Create a PeripheralManagerService 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>

getI2sDeviceList

List<String> getI2sDeviceList ()

Get the list of I2s devices available.

Returns
List<String>

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.

openI2sDevice

I2sDevice openI2sDevice (String name, 
                AudioFormat format)

This method is deprecated.
Use openI2sDevice(String, AudioFormat, int) instead.

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

Parameters
name String: Name of the I2s bus as returned by getI2sDeviceList().
format AudioFormat: AudioFormat specifying encoding, bits per sample, channels and rate.
Returns
I2sDevice The I2sDevice object.
Throws
IOException Failed to open the named I2s bus.

openI2sDevice

I2sDevice openI2sDevice (String name, 
                AudioFormat format, 
                int flags)

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

Parameters
name String: Name of the I2s bus as returned by getI2sDeviceList().
format AudioFormat: AudioFormat specifying encoding, bits per sample, channels and rate.
flags int: Flags to indicate input and/or output.
Returns
I2sDevice The I2sDevice object.
Throws
IOException Failed to open the named I2s bus.

openI2sDevice

I2sDevice openI2sDevice (String name, 
                int encoding, 
                int channels, 
                int rate, 
                int flags)

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

Parameters
name String: Name of the I2s bus as returned by getI2sDeviceList().
encoding int: Int specifying encoding. Can be one of I2sDevice.PCM_FORMAT_*
channels int: Number of channels.
rate int: Sample rate in Hz.
flags int: Flags to indicate input and/or output.
Returns
I2sDevice The I2sDevice object.
Throws
IOException Failed to open the named I2s bus.

openI2sDevice

I2sDevice openI2sDevice (String name, 
                int encoding, 
                int channels, 
                int rate)

This method is deprecated.
Use openI2sDevice(String, int, int, int, int) instead.

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

Parameters
name String: Name of the I2s bus as returned by getI2sDeviceList().
encoding int: Int specifying encoding. Can be one of I2sDevice.PCM_FORMAT_*
channels int: Number of channels.
rate int: Sample rate in Hz.
Returns
I2sDevice The I2sDevice object.
Throws
IOException Failed to open the named I2s bus.

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

Follow Google Developers on WeChat

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 short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)