DART-SD410 Android Examples: Difference between revisions

From Variscite Wiki
Line 104: Line 104:
*PMIC gpio is 897
*PMIC gpio is 897
*PMIC mpp is 901
*PMIC mpp is 901
= Using I2C =
= Using RTC =
There are two RTC devices defined in the system. One is inside DART-SD410 PMIC chip and the second is on VART-DT410CustomBoard.<br/>
The main RTC device is DS1307 that is assembled on VART-DT410CustomBoard.
It can be accessed via console in the following manner:
<pre>
$ su
# cd /sys/class/rtc/rtc0
# cat date
Output similar to 2000-01-01
# cat time
Output similar to 00:00:36
</pre>
To set the timezone use:
<pre>
# setprop persist.sys.timezone "America/Chicago"
</pre>
To set the time and date use:
<pre>
# date -s 20160119.122100
The format is YYYYMMDD.HHmmss
</pre>
To read back from the RTC0 device use:
<pre>
# cat date
Output is 2016-01-19
# cat time
Output is 18:21:04
Pay attention that RTC stores time without timezone offset
</pre>
= using =

Revision as of 12:15, 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.

To see all allocated GPIOs in the system type:

# cat /sys/kernel/debug/gpio
The output will be:
GPIOs 577-608, platform/qcom,smp2pgpio-ssr-smp2p-4-out.19, master-kernel:
GPIOs 609-640, platform/qcom,smp2pgpio-ssr-smp2p-4-in.18, slave-kernel:
GPIOs 641-672, platform/qcom,smp2pgpio-ssr-smp2p-1-out.13, master-kernel:
GPIOs 673-704, platform/qcom,smp2pgpio-ssr-smp2p-1-in.12, slave-kernel:
GPIOs 705-736, platform/qcom,smp2pgpio-smp2p-4-out.16, smp2p:
GPIOs 737-768, platform/qcom,smp2pgpio-smp2p-4-in.14, smp2p:
GPIOs 769-800, platform/qcom,smp2pgpio-smp2p-1-out.10, smp2p:
GPIOs 801-832, platform/qcom,smp2pgpio-smp2p-1-in.8, smp2p:
GPIOs 833-864, platform/qcom,smp2pgpio-smp2p-7-out.6, smp2p:
GPIOs 865-896, platform/qcom,smp2pgpio-smp2p-7-in.4, smp2p:
GPIOs 897-900, spmi/qpnp-pin-ffffffc0319b4c00, pm8916-gpio:
 gpio-899 (qcom,hub-reset-gpio ) out hi
 gpio-900 (qcom,sw-sel-gpio    ) in  lo
GPIOs 901-901, spmi/qpnp-pin-ffffffc0319b4800, pm8916-mpp:
GPIOs 902-1023, platform/1000000.pinctrl, msm_tlmm_gpio:
 gpio-914 (ft5x06_reset_gpio   ) out hi
 gpio-915 (ft5x06_irq_gpio     ) in  hi
 gpio-922 (adv7533_hpd_irq_gpio) in  lo
 gpio-923 (led1                ) out lo
 gpio-933 (adv7533_irq_gpio    ) in  hi
 gpio-934 (disp_rst_n          ) in  hi
 gpio-940 (7864900.sdhci cd    ) in  lo
 gpio-1009 (volume_up           ) in  hi
 gpio-1010 (home                ) in  hi
 gpio-1011 (back                ) in  hi
 gpio-1022 (sysfs               ) out lo
 gpio-1023 (USB_ID_GPIO         ) in  hi

From this table you can see that offsets are:

  • CPU gpio is 902
  • PMIC gpio is 897
  • PMIC mpp is 901

Using RTC

There are two RTC devices defined in the system. One is inside DART-SD410 PMIC chip and the second is on VART-DT410CustomBoard.
The main RTC device is DS1307 that is assembled on VART-DT410CustomBoard. It can be accessed via console in the following manner:

$ su
# cd /sys/class/rtc/rtc0
# cat date
Output similar to 2000-01-01
# cat time
Output similar to 00:00:36

To set the timezone use:

# setprop persist.sys.timezone "America/Chicago"

To set the time and date use:

# date -s 20160119.122100
The format is YYYYMMDD.HHmmss

To read back from the RTC0 device use:

# cat date
Output is 2016-01-19
# cat time
Output is 18:21:04
Pay attention that RTC stores time without timezone offset

using