Oracle® Java ME Embedded Getting Started Guide for the Reference Platform (Raspberry Pi) Release 8 EA 2 E48512-02 |
|
Previous |
Next |
Beta Draft: 2014-03-25
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 tables use the following legend:
DA API Peripheral Id - an integer identifier that can be used to open the peripheral with a PeripheralManager
.
DA API Peripheral Name - the string name of a peripheral that can be used to open it by name with PeripheralManager
.
Mapped To - all hardware related information regarding a peripheral, such as physical location, mapping, or port. This information enables the user to find out the peripheral's location on a target board. See the following site for more information:
Configuration - properties that are passed to the specific PeripheralConfig
constructor in order to open the peripheral by ID or name. The configuration can be used to open the peripheral using the PeripheralManager
with the appropriate configuration.
Please note the following items for Device Access in the Raspberry Pi board:
All device access permissions are not checked (including ADCPermission
, ATPermission
, CounterPermission
, DACPermission
, GenericPermission
, GPIOPinPermission
, GPIOPortPermission
, I2CPermission
, MMIOPermission
, PWMPermission
, SPIPermission
, UARTPermission
, WatchdogTimerPermission
)
Direct NIO buffers are not implemented in the most efficient way. This means that direct NIO buffers are copied when they are passed to and from the native layer.
Interface PeripheralConfig.HardwareAddressing
does not support device names. Please do not use the PeripheralConfig.HardwareAddressing.getDeviceName()
method.
No devices support shared access mode. Only exclusive mode is supported.
No generic device is implemented, as would be accessed using the package com.oracle.deviceaccess.generic
.
The MMIOEvent
class is not supported.
The com.oracle.deviceaccess.power
package does not support the actual hardware power state switch.
The present implementation utilizes the I2C bus STOP-START sequence instead of REPEATED START, keeping a combined message uninterrupted by another transactions on the same I2C bus.
The PulseCounter
cannot be opened by the PulseCounterConfig
with the GPIOPin
or GPIOPinConfig
specified.
PWMChannel
cannot be opened by PWMChannelConfig
with GPIOPin
or GPIOPinConfig
specified.
The following GPIO pins are pre-configured.
DAAPI Peripheral ID | DAAPI Peripheral Name | Mapped To | Configuration |
---|---|---|---|
2 |
GPIO2 |
GPIO 2 |
portNumber = 0 pinNumber = 2 direction = GPIOPinConfig.DIR_INPUT_ONLY mode = GPIOPinConfig.MODE_INPUT_PULL_UP trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue - ignored |
3 |
GPIO3 |
GPIO 3 |
portNumber = 0 pinNumber = 3 direction = GPIOPinConfig.DIR_INPUT_ONLY mode = GPIOPinConfig.MODE_INPUT_PULL_UP trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue - ignored |
4 |
GPIO4 |
GPIO 4 |
portNumber = 0 pinNumber = 4 direction = GPIOPinConfig.DIR_INPUT_ONLY mode = PeripheralConfig.DEFAULT trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue - ignored |
7 |
GPIO7 |
GPIO 7 |
portNumber = 0 pinNumber = 7 direction = GPIOPinConfig.DIR_OUTPUT_ONLY mode = GPIOPinConfig.MODE_OUTPUT_PUSH_PULL trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue = false |
8 |
GPIO8 |
GPIO 8 |
portNumber = 0 pinNumber = 8 direction = GPIOPinConfig.DIR_OUTPUT_ONLY mode = GPIOPinConfig.MODE_OUTPUT_PUSH_PULL trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue = false |
9 |
GPIO9 |
GPIO 9 |
portNumber = 0 pinNumber = 9 direction = GPIOPinConfig.DIR_INPUT_ONLY mode = PeripheralConfig.DEFAULT trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue - ignored |
10 |
GPIO10 |
GPIO 10 |
portNumber = 0 pinNumber = 10 direction = GPIOPinConfig.DIR_INPUT_ONLY mode = PeripheralConfig.DEFAULT trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue - ignored |
11 |
GPIO11 |
GPIO 11 |
portNumber = 0 pinNumber = 11 direction = GPIOPinConfig.DIR_INPUT_ONLY mode = PeripheralConfig.DEFAULT trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue - ignored |
14 |
GPIO14 |
GPIO 14 |
portNumber = 0 pinNumber = 14 direction = GPIOPinConfig.DIR_OUTPUT_ONLY mode = GPIOPinConfig.MODE_OUTPUT_PUSH_PULL trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue = false |
15 |
GPIO15 |
GPIO 15 |
portNumber = 0 pinNumber = 15 direction = GPIOPinConfig.DIR_OUTPUT_ONLY mode = GPIOPinConfig.MODE_OUTPUT_PUSH_PULL trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue = false |
17 |
GPIO17 |
GPIO 17 |
portNumber = 0 pinNumber = 17 direction = GPIOPinConfig.DIR_INPUT_ONLY mode = PeripheralConfig.DEFAULT trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue - ignored |
18 |
GPIO18 |
GPIO 18 |
portNumber = 0 pinNumber = 18 direction = GPIOPinConfig.DIR_OUTPUT_ONLY mode = GPIOPinConfig.MODE_OUTPUT_PUSH_PULL trigger - ignored initValue = false |
22 |
GPIO22 |
GPIO 22 |
portNumber = 0 pinNumber = 22 direction = GPIOPinConfig.DIR_INPUT_ONLY mode = PeripheralConfig.DEFAULT trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue - ignored |
23 |
GPIO23 |
GPIO 23 |
portNumber = 0 pinNumber = 23 direction = GPIOPinConfig.DIR_OUTPUT_ONLY mode = GPIOPinConfig.MODE_OUTPUT_PUSH_PULL trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue = false |
24 |
GPIO24 |
GPIO 24 |
portNumber = 0 pinNumber = 24 direction = GPIOPinConfig.DIR_OUTPUT_ONLY mode = GPIOPinConfig.MODE_OUTPUT_PUSH_PULL trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue = false |
25 |
GPIO25 |
GPIO 25 |
portNumber = 0 pinNumber = 25 direction = GPIOPinConfig.DIR_OUTPUT_ONLY mode = GPIOPinConfig.MODE_OUTPUT_PUSH_PULL trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue = false |
27 |
GPIO27 |
GPIO 27 |
portNumber = 0 pinNumber = 27 direction = GPIOPinConfig.DIR_INPUT_ONLY mode = PeripheralConfig.DEFAULT trigger = GPIOPinConfig.TRIGGER_BOTH_EDGES initValue - ignored |
Please note the following items concering GPIO on the Raspberry Pi.
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.
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.
The following MMIO peripherals are available:
DAAPI Peripheral ID | DAAPI Peripheral Name | Mapped To | Configuration |
---|---|---|---|
61 |
PWM |
The MMIO peripherals include CTL, STA, RNG1, DAT1, and FIF1 registers (all of them are of type INT) with no event support.
Due to nature of memory organization of the Raspberry Pi, programmers can create a custom MMIODeviceConfig
to access the memory range {0x20000000, 0x21000000}. Please note that not all addresses are accessible in the range and some of them may cause a board reboot. Please check the documentation for SFR addresses and its behavior. The end addresses are not inclusive.
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 8-bit word lengths are supported on the Raspberry Pi.
Note: No predefined configuration is available in the Early Access release. |
The following UART devices are pre-configured:
DAAPI Peripheral ID | DAAPI Peripheral Name | Mapped To | Configuration |
---|---|---|---|
40 |
UART |
GPIO 14 (TXD)GPIO 15 (RXD) |
uartNumber = 0 (see below)baudRate = 19200dataBits = DATABITS_8parity = PARITY_NONEstopBits = STOPBITS_1flowcontrol = FLOWCONTROL_NONEinputBufferSize - ignoredoutputBufferSize - ignored |
Please note the following items about UART on the Raspberry Pi.
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.
The following parameters are supported in an ad-hoc configuration:
baudRate
- 110, 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200
dataBits
- 7, 8
parity
- PARITY_ODD, PARITY_EVEN, PARITY_NONE
stopBits
- 1, 2
flowcontrol
- FLOWCONTROL_NONE