User manual
6 OnRISC Hardware API
6.6. I2C
I2C
54
(Inter-Integrated Circuit) is a multi-master serial computer bus. In the OnRISC integrated
I2C controller is already supported by the mainline kernel. A good starting point on how to use
I2C is the hwtest utility (see Section C.6). test_LCD() routine from hwtest/module_i2c.c shows
how to communicate with an I2C device. Additional information can be found in the Linux kernel
documentation Documentation/i2c. I2C platform device initialization is described in
Documentation/i2c/instantiating-devices.
6.7. WLAN Button (Alekto LAN Only)
OnRISC Alekto LAN provides an additional button. By default this button is used to control
WLAN card’s transmit power. This button is just connected to GPIO line and will be controlled
by wland service (refer to Section 4.1.3). To use it for other needs just disable the wland service.
Following ioctl command for /dev/gpio is provided to get button’s state:
GPIO_CMD_GET_BTN_WLAN
return value is 0 - for not pressed and 1 - for pressed.
6.8. Watchdog Timer
The OnRISC provides a watchdog timer
55
(WDT) that can work in intervals from 1 second to
maximal 171 seconds. The access to the WDT occurs via /dev/watchdog device. After starting
the WDT it should be turned off or reloaded after the critical part otherwise the system will reboot.
Table 6 shows the most important IOCTLs to control WDT.
IOCTL Description
WDIOC_SETTIMEOUT set timeout and start the timer
WDIOC_GETTIMEOUT get timeout
WDIOC_SETOPTIONS enable (WDIOS_ENABLECARD)
disable (WDIOS_DISABLECARD) the timer
WDIOC_KEEPALIVE reload the timer
Table 6: Watchdog Timer IOCTLs
The WDT driver provides a special option called "Disable watchdog shutdown on close" to prevent
stopping the timer on WDT descriptor close (see Figure 4). This is a compile-time option. It is
deactivated by default, so you have to build your own kernel if you need it.
See examples/wdtimer.c for WDT usage example.
54
http://en.wikipedia.org/wiki/I2C
55
For further information see drivers/watchdog/ks8695_wdt.c
May 2014 OnRISC User Manual 47