DART-SD410 Android Examples: Difference between revisions

From Variscite Wiki
Line 38: Line 38:
</pre>
</pre>
= Using GPIO =
= Using GPIO =
User LED2 (D9) connected to GPIO120 of the CPU. The LED1 is not defined in the apq8016-var-dt410.dtsi file under gpio-leds section.</br>
This allow user acces to this LED as GPIO device.
To change the state of the LED via serial console type:
<pre>
$ su
# cd /sys/class/gpio
# echo 1022 > export
This line creates a new directory gpio1022
The number 1022 calculated as 120 + 902. 120 is the GPIO number, 902 is static offset for CPU gpio.
So changing any other GPIO will lead to 902 + GPIO number.
# cd gpio1022
# echo out > direction
# echo 1 > value
The led will turn on
#echo 0 > value
The led will turn off
</pre>
To read the current state type:
<pre>
# cat value
The output will be 0
</pre>
You can change active state to active low.
<pre>
# echo 1 > active_low
# echo 0 > value
The led is active low, writing 0 will turn on the led.
# echo 1 > value
The led is active low, writing 1 will turn off the led.
</pre>

Revision as of 10:39, 19 January 2016

DART-SD410 - Using Peripherals

This WIKI describes how to use some simple peripheral devices available on VAR-DT410CustomBoard.

Using User LED1

User LED1 (D6) connected to GPIO21 of the CPU. The LED1 is defined in the apq8016-var-dt410.dtsi file under gpio-leds section.

general1 {
	gpios = <&msm_gpio 21 0>;
	label = "led1";
	linux,default-trigger = "none";
	default-state = "off";
	retain-state-suspended;
};

You can access the LED device via serial console by:

$ su 
# cd /sys/class/leds/led1
# echo 1 > brightness
Writing any value other then 0 will turn the led on
# echo 0 > brightness
The led will turn off

You can view available triggers by typing:

# cat trigger
The output will be:
[none] boot-indication usb-online mmc0 mmc1 battery-charging-or-full battery-charging battery-full battery-charging-blink-full-solid wlan-indication-led

Set the trigger to mmc0 device by typing:

# echo mmc0 > trigger

Test it by reading mmc0 device:

# dd if=/dev/block/mmcblk0 of=/dev/null bs=128 count=1000000

Using GPIO

User LED2 (D9) connected to GPIO120 of the CPU. The LED1 is not defined in the apq8016-var-dt410.dtsi file under gpio-leds section.
This allow user acces to this LED as GPIO device. To change the state of the LED via serial console type:

$ su
# cd /sys/class/gpio
# echo 1022 > export
This line creates a new directory gpio1022
The number 1022 calculated as 120 + 902. 120 is the GPIO number, 902 is static offset for CPU gpio.
So changing any other GPIO will lead to 902 + GPIO number.
# cd gpio1022
# echo out > direction
# echo 1 > value
The led will turn on
#echo 0 > value
The led will turn off

To read the current state type:

# cat value
The output will be 0

You can change active state to active low.

# echo 1 > active_low
# echo 0 > value
The led is active low, writing 0 will turn on the led.
# echo 1 > value
The led is active low, writing 1 will turn off the led.