User manual

6 OnRISC Hardware API
6. OnRISC Hardware API
KS8695 based Devices Such hardware as digital I/O, buzzer, serial interfaces will be controlled
via IOCTL commands. These commands are defined in the onrisc.h header file. Almost all
IOCTL commands are reflected in the /proc-filesystem (see Section 7).
To control the hardware the /dev/gpio device must be opened:
int f d ;
fd = open ( " /dev / g pi o " , O_RDWR) ;
i f ( fd < 0)
e x i t ( 1) ;
Listing 3: Open /dev/gpio
Some examples for the OnRISC hardware are provided in the examples/ioctls.c and
examples/ioctls2.c. For the usage in real applications see the source code of the Hardware Test
Utility (hwtest provided on SVN repository).
OMAP3 based Devices Such hardware as digital I/O, serial interfaces, USB OTG will be con-
trolled through sysfs GPIO entries. To simplify this task onrisctool.py (see Section Section B)
provides a convenient access to these hardware from user space. A good starting point of how to
access these interfaces from C/C++ and/or Python is the source code of hwtest-qt provided on
SVN repository.
6.1. Digital I/O
6.1.1. KS8695 based Devices
The OnRISC provides up to 8 digital input/output channels, 2 optically isolated inputs and 2
relays
46
. The data direction for each I/O channel (not for optically isolated inputs or relays) can
be independently set to input (bit value 0) or output (bit value 1). An interrupt for an input channel
can also be independently enabled (bit value 1 enables interrupt, bit value 0 disables interrupt for
the desired channel). The physical driver operates with 32mA for both high and low level. For
digital I/O usage four registers are provided:
data register - reflected in /proc/vscom/gpio_data
data direction register - reflected in /proc/vscom/gpio_ctrl
interrupt mask register - reflected in /proc/vscom/gpio_irqmask
status register (read only) - reflected in /proc/vscom/gpio_change
In addition the interrupts will be counted for each pin.
Following IOCTL commands are defined in onrisc.h to control digital I/O:
GPIO_CMD_GET/GPIO_CMD_SET - set/get data register value
46
OnRISC Alekto provides 8 digital I/O channels only, OnRISC Alena provides 4 digital I/O channels, 2 optically
isolated inputs and 2 relays
May 2014 OnRISC User Manual 39