第9章 Other Devices

9.1. LED

The Armadillo-400 Series LEDs are supported as LED class devices. The LEDs can be controlled with the files under the LED class directories. For the LED class directories and corresponding LEDs, refer to 表9.1「LEDs and LED Class Directories」.

表9.1 LEDs and LED Class Directories

LED Class DirectoryDescription
/sys/class/leds/red/LED3 (red)
/sys/class/leds/green/LED4 (green)
/sys/class/leds/yellow/LED5 (yellow)

9.1.1. Activating and Deactivating LEDs

LEDs can be turned on and off by writing an appropriate value to the brightness file under the LED class directory. A value between 0 and 255 can be written to the brightness file.

Writing any value apart from 0 to the brightness file turns the LED on. As the Armadillo-400 Series LEDs do not have brightness control functionality, the value has no effective meaning.

[armadillo ~]# echo 1 > /sys/class/leds/yellow/brightness

図9.1 Turning LED5 On


Writing 0 to the brightness file turns the LED off.

[armadillo ~]# echo 0 > /sys/class/leds/yellow/brightness

図9.2 Turning LED5 Off


The current state of the LED can be obtained by reading the brightness file. 0 represents the off state, and any other value represents an on state.

[armadillo ~]# cat /sys/class/leds/yellow/brightness
0

図9.3 Displaying LED5 State


9.1.2. Using Triggers

A trigger to turn the LED on and off can be set by writing an appropriate value to the trigger file under the LED class directory. For values supported by the trigger file, refer to 表9.1「LEDs and LED Class Directories」.

表9.2 trigger Configuration

ConfigurationDescription
noneNo trigger is set.
mmc0LED acts as microSD card access lamp.
timerBlink on and off at certain intervals. After setting this trigger, delay_on and delay_off files appear under the LED class directory which can be used to set the on and off times in millisecond increments.
heartbeatBlink on and off like a heart beat.
default-onUsed mainly from the kernel. The LED is turned on at boot time.

Executing the commands below will cause LED3 to repeatedly turn on for 1 second and then off for 500 milliseconds.

[armadillo ~]# echo timer > /sys/class/leds/red/trigger
[armadillo ~]# echo 1000 > /sys/class/leds/red/delay_on
[armadillo ~]# echo 500 > /sys/class/leds/red/delay_off

図9.4 Specifying timer As Trigger For LED3


The current trigger of the LED can be obtained by reading the trigger file. The value enclosed in [] is the current trigger.

[armadillo ~]# cat /sys/class/leds/yellow/trigger
[none] mmc0 timer heartbeat default-on

図9.5 Displaying LED3 Timer


9.2. GPIO

The Armadillo-400 Series GPIO are supported as GPIO class devices. The GPIO can be controlled with the files under the GPIO class directories. For the GPIO class directories and corresponding GPIO, refer to 表9.3「GPIO and GPIO Class Directories」.

表9.3 GPIO and GPIO Class Directories

GPIO Class DirectoryDescription
/sys/class/gpio/CON9_1/CON9 pin 1
/sys/class/gpio/CON9_2/CON9 pin 2
/sys/class/gpio/CON9_11/CON9 pin 11
/sys/class/gpio/CON9_12/CON9 pin 12
/sys/class/gpio/CON9_13/CON9 pin 13
/sys/class/gpio/CON9_14/CON9 pin 14
/sys/class/gpio/CON9_15/CON9 pin 15
/sys/class/gpio/CON9_16/CON9 pin 16
/sys/class/gpio/CON9_17/CON9 pin 17
/sys/class/gpio/CON9_18/CON9 pin 18
/sys/class/gpio/CON9_21/CON9 pin 21
/sys/class/gpio/CON9_22/CON9 pin 22
/sys/class/gpio/CON9_23/CON9 pin 23
/sys/class/gpio/CON9_24/CON9 pin 24
/sys/class/gpio/CON9_25/CON9 pin 25
/sys/class/gpio/CON9_26/CON9 pin 26
/sys/class/gpio/CON9_27/CON9 pin 27
/sys/class/gpio/CON9_28/CON9 pin 28

[警告]

CON14 pin 3 and CON14 pin 4 were configured to be used as GPIO by default in linux-2.6.26-at7 (linux-a400-1.00.bin.gz). In linux-2.6.26-at8 (linux-a400-1.01.bin.gz) and later, this was changed so that they are configured to be used as I2C2 by default. Please be aware of this change when using CON14 pin 3 and CON14 pin 4.

9.2.1. Changing I/O Direction

The I/O direction can be changed by writing an appropriate value to the direction file under the GPIO class directory. For values supported by the direction file, refer to 表9.4「direction Configuration」.

表9.4 direction Configuration

ConfigurationDescription
highSet I/O direction to OUTPUT. The input level can be obtained and set in this state. The input level will be HIGH.
outSet I/O direction to OUTPUT. The input level can be obtained and set in this state. The input level will be LOW.
lowThis is the same as setting "out".
inSet I/O direction to INPUT. The input level can be obtained but not set in this state.

9.2.2. Obtaining Input Level

The input level can be obtained by reading the value file under the GPIO class directory. 0 represents a LOW level and 1 a HIGH level. The input level can be obtained both when the I/O direction is set to INPUT and OUTPUT.

[armadillo ~]# cat /sys/devices/virtual/gpio/CON9_1/value
0

図9.6 Obtaining CON9_1 Input Level


9.2.3. Configuring Input Level

The input level can be set by writing an appropriate value to the value file under the GPIO class directory. 0 represents a LOW level and 1 a HIGH level. Input level configuration can only be carried out when the I/O direction is set to OUTPUT.

[armadillo ~]# echo 1 > /sys/devices/virtual/gpio/CON9_2/value

図9.7 Configuring CON9_2 Input Level


9.3. RTC

As the Armadillo-440 LCD Model incorporates a calendar clock (Real Time Clock), the date and time will continue to be displayed correctly even after turning the power off and on.

To set time information to the RTC, first set the system clock. After that, then set the hardware clock (RTC) to match the system clock.

9.3.1. Setting System Clock With date

The time format used as an argument to the date command is: MMDDhhmmCCYY.ss. In the example below, the date and time are set to 1/23/2000 4:56:00.

[armadillo ~]#date Displays the current system clock
[armadillo ~]#date 012304562000.00
[armadillo ~]#date
Check that the system clock was set correctly
      

9.3.2. Setting System Clock With NTP Client

The system clock can be set using the NTP client. For more information, refer to 「NTP Client」.

9.3.3. Setting Hardware Clock

[armadillo ~]#hwclock Displays the hardware clock
[armadillo ~]#hwclock --utc --systohc Sets hardware clock in UTC
[armadillo ~]#hwclock
Check that the hardware clock was set correctly