A Raspberry Pi Board Peripheral List

This appendix describes the proper ID and names for the various peripheral ports and buses for the Raspberry Pi embedded board, which are accessible using the Device Access APIs. Note that any IMlet that accesses the Device Access APIs must be digitally signed using a trusted certificate authority. An IMlet that is not signed will encounter an authentication error when attempting to access the Device Access APIs.

The value of PeripheralConfig.DEFAULT when applied to the portNumber is 0.

The value of PeripheralConfig.DEFAULT when applied to the mode means that the GPIO pin be configured in the default mode, as per the table above.

GPIO modes are not software-configurable. All GPIO pins in the preceding table are given with the only mode that is supported on the Raspberry Pi. If an application attempts to configure a GPIO pin to use an unsupportable mode, an exception will be thrown.

To work with GPIO, you must run Java as the root superuser.

For GPIO pins that are configured as input pins, the initValue parameter is ignored.

The trigger modes TRIGGER_HIGH_LEVEL, TRIGGER_LOW_LEVEL, and TRIGGER_BOTH_LEVELS are not supported on the Raspberry Pi.

For all GPIO pins, the application should pass in a 0 for the GPIO port when necessary.

The following diagram represents the pin positions of the Raspberry Pi, Revision 2.

I2C

There is no static I2C configuration with the Raspberry Pi because there is no connected hardware. In comparison with SPI, I2C doesn't allow any communication with a loopback device. The following configuration, however, can be used to communicate to I2C slaves.

DAAPI Peripheral ID

DAAPI Peripheral Name

Mapped To

Configuration

NONE

GPIO 2 (SDA)

GPIO 3 (SCL)

Please note the following items about I2C on the Raspberry Pi.

For revision 1 boards, I2C is provided by default on GPIO 0 and 1 (bus 0), and for revision 2 boards, I2C is provided on GPIO 2 and 3 (bus 1). For example, Example to configure a TCS3414-A I2C color sensor on a revision 2 Raspberry Pi board, use the following constructor: I2CDeviceConfig(1, 57, 7, 100000)

The value of PeripheralConfig.DEFAULT when applied to the busNumber is 0.

The value of PeripheralConfig.DEFAULT when applied to the addressSize is 7.

The clockFrequency field is ignored.

Before using I2C, you will have to load two I2C modules: i2c-bcm2708 ( this is probably commented out in the file /etc/modprobe.d/raspi-blacklist.conf; simply uncomment it and reboot the device to apply the changes) and i2c-dev (you can add i2c-dev, without quotes, to the /etc/modules file and reboot to apply the changes).

I2C can be used without administrative rights. To do so, you should have owner or group rights to files /dev/i2c-*. This can easily done by installing the i2c-tools package ($ sudo apt-get install i2c-tools) and adding the pi user to the i2c group ($ sudo adduser pi i2c). Alternatively, you can use udev's rules.

MMIO

The following MMIO peripherals are available:

DAAPI Peripheral ID

DAAPI Peripheral Name

Mapped To

Configuration

31

PWM

byteOrdering = Peripheral.LITTLE_ENDIAN

The MMIO raw memories are shown here:

DAAPI Peripheral ID

Name

Address

Type and Size

31

CTL

0x7e20C000

int 4

31

STA

0x7e20C004

int 4

31

RNG1

0x7e20C010

int 4

31

DAT1

0x7e20C014

int 4

31

FIF1

0x7e20C018

int 4

There are no devices with event support. Due to nature of memory organization of the Raspberry Pi, programmers can create a custom MMIODeviceConfig to access the following memory ranges. Note that all are IO Peripheral register ranges with exclusion of DMA regsiters. The end addresses are not inclusive.

{0x7E215000, 0x7E2150D8},

{0x7E205000, 0x7E20501f},

{0x7E804000, 0x7E80401f},

{0x7E805000, 0x7E80501f},

{0x7E300000, 0x7E3000ff},

{0x7E200000, 0x7E2000B4},

{0x7E203000, 0x7E203024},

{0x7e20C000, 0x7e20C028},

{0x7E204000, 0x7E204018},

{0x7E214000, 0x7E21403f},

{0x7E003000, 0x7E00301b},

{0x7E201000, 0x7E20108f},

{0x7E00B400, 0x7E00B424}

Only int types for the memory configuration are allowed. Otherwise, an IOException will be thrown.

SPI

The SPI has a single static configuration with the following parameters:

DAAPI Peripheral ID

DAAPI Peripheral Name

Mapped To

Configuration

12

SPI_Slave

GPIO10 (MOSI)GPIO9 (MISO)GPIO11 (SCLK)GPIO8 (CE0)

SPI bus number: 0 (SPI1)

Chip Enable: 0 (CE0/GPIO8)

The number of bit of slave's word: 8

Clock frequency in Hz: 2000000

Clock polarity and phase: 1 (CPOL_Low, CPHA_2Edge)

Bit ordering of the slave device: 1 (BIG_ENDIAN)

Please note the following items about SPI on the Raspberry Pi.

The value of PeripheralConfig.DEFAULT when applied to the busNumber is 0.

The value of PeripheralConfig.DEFAULT when applied to the clockFrequency is 2000000 Hz.

The value of PeripheralConfig.DEFAULT when applied to the wordLength is 8.

The value of PeripheralConfig.DEFAULT when applied to the bitOrdering is 1 (big-endian).

Before using SPI, you will have to load the SPI modules by running the following command: $sudo modprobe spi_bcm2708, or by using the same method as I2C: uncomment the appropriate line in the raspi-blacklist.conf file and reboot the board.

Only the internal UART controller is supported (/dev/ttyAMA0 for revision 2). Consequently, 0 is the only permissible value for the UARTConfig.uartNumber parameter.

By default, the Raspberry Pi uses the UART as a serial console. Before using UART, make sure that /dev/ttyAMA0 isn't being used as a console. This can be done by changing the boot command line by editing the /boot/cmdline.txt file and removing the line "console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" from the boot arguments. Also, comment out the following line: "2:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100" in the file /etc/inittab.

By default, the pi user is in the dialout group. That gives pi the ability to access /dev/ttyAMA0 (and, consequently, UART from Java) without administrator rights.

The deviceaccess.uart.prefix property in the jwc_properties.ini file may contain a prefix for easy conversion of the UARTConfig.portNumber value to a platform-specific port name. For example, the property may be set to "COM" in a Windows environement, or "/dev/ttyS" in a Linux environment such that appending on a port number will correctly map to the port name.