Changes

Jump to: navigation, search
Created page with "{{InfoBoxTop}} {{AppliesToAXEL Lite AN}} {{InfoBoxBottom}} ==History== {| class="wikitable" border="1" !Date !Development Kit version |- | 2024/01/22 |DESK-MX6-L/General/R..."
{{InfoBoxTop}}
{{AppliesToAXEL Lite AN}}
{{InfoBoxBottom}}

==History==

{| class="wikitable" border="1"
!Date
!Development Kit version
|-
| 2024/01/22
|[[DESK-MX6-L/General/Release_Notes#DESK-MX6-L_4.0.1|DESK-MX6L-L 4.0.1]]
|-
|}

==Introduction==
Using leds and pushbuttons allows to have a simple user interaction with the userspace application.

It is possible to add a simple PCB adapter to the AXEL Lite Evaluation Kit [[AXEL_Lite_SOM/AXEL_Lite_Evaluation_Kit/Interfaces_and_Connectors/WIDE | WIDE connector]].

This Application Note (AN) shows how to use it on a system running a DESK-MX6-L-based Yocto Linux distribution in Linux userspace.

== Hardware adapter ==

A simple hardware PCB has been designed with 4 LEDS and 4 KEYs (pushbutton) useful for adding an easy visual and input interface to the [[AXEL_Lite_SOM/AXEL_Lite_Evaluation_Kit | AXEL Lite Evaluation Kit]].

[[File:SBCX_4K4L.png | thumb | center | 200px| 4 kyes - 4 leds SBCX Add-on]]

The schematics for this adapter can be downloaded from our [cloud server]:

== Linux device tree==
The device tree has to be properly modified for configuring the adapter pins with the related pads pinmuxing.

=== gpio-leds ===
In the <code>imx6dl-sbcx-cb0012.dts</code> device tree, the <code>gpio-leds</code> driver can be used for configuring the leds interface in <code>/sys/class/leds</code> sysfs filesystem:

<pre>
leds {
compatible = "gpio-leds";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sbcx_leds>;

led0 {
label = "led0";
gpios = <&gpio3 21 GPIO_ACTIVE_HIGH>;
default-state = "off";
};

led1 {
label = "led1";
gpios = <&gpio3 22 GPIO_ACTIVE_HIGH>;
default-state = "off";
};

led2 {
label = "led2";
gpios = <&gpio3 28 GPIO_ACTIVE_HIGH>;
default-state = "off";
};

led3 {
label = "led3";
gpios = <&gpio3 20 GPIO_ACTIVE_HIGH>;
default-state = "off";
};

};
};
</pre>

The related pinctrl has to be added for configuring the pads:
<pre>
&iomuxc {
pinctrl-names = "default";

pinctrl_sbcx_leds: ledgrp-1 {
fsl,pins = <
MX6QDL_PAD_EIM_D21__GPIO3_IO21 0x1b0b1 /* LED0 - gpio85 */
MX6QDL_PAD_EIM_D22__GPIO3_IO22 0x1b0b1 /* LED1 - gpio86 */
MX6QDL_PAD_EIM_D28__GPIO3_IO28 0x1b0b1 /* LED2 - gpio92 */
MX6QDL_PAD_EIM_D20__GPIO3_IO20 0x1b0b1 /* LED3 - gpio84 */
>;
};
</pre>

=== gpio-keys ===
In the <code>imx6dl-sbcx-cb0012.dts</code> device tree, the <code>gpio-keys</code> driver can be used for adding a new input interface. The related entry in <code>/dev/input/event1</code> will be populated by the kernel driver:

<pre>
gpio-push-button {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_push_button>;

key0 {
label = "GPIO F1";
gpios = <&gpio3 26 GPIO_ACTIVE_LOW>;
linux,code = <KEY_F1>;
};

key1 {
label = "GPIO F2";
gpios = <&gpio3 27 GPIO_ACTIVE_LOW>;
linux,code = <KEY_F2>;
};

key2 {
label = "GPIO F3";
gpios = <&gpio7 12 GPIO_ACTIVE_LOW>;
linux,code = <KEY_F3>;
};

key3 {
label = "GPIO F4";
gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
linux,code = <KEY_F4>;
};
};
</pre>

The related pinctrl has to be added for configuring the pads:

<pre>
pinctrl_gpio_push_button: gpio_push_button {
fsl,pins = <
MX6QDL_PAD_EIM_D26__GPIO3_IO26 0x1b0b0 /* KEY0 - gpio 3 26 */
MX6QDL_PAD_EIM_D27__GPIO3_IO27 0x1b0b0 /* KEY1 - gpio 3 27 */
MX6QDL_PAD_GPIO_17__GPIO7_IO12 0x1b0b0 /* KEY2 - gpio 7 12 */
MX6QDL_PAD_GPIO_6__GPIO1_IO06 0x1b0b0 /* KEY3 - gpio 1 6 */
>;
};
</pre>

=== Userspace commands ===
The configured leds and keys can be checked using the <code>/sys/kernel/debug/gpio</code> interface:

<pre>
root@desk-mx6:~# cat /sys/kernel/debug/gpio | grep "led"
gpio-84 ( |led3 ) out lo
gpio-85 ( |led0 ) out lo
gpio-86 ( |led1 ) out lo
gpio-92 ( |led2 ) out lo
root@desk-mx6:~# cat /sys/kernel/debug/gpio | grep "GPIO F"
gpio-6 ( |GPIO F4 ) in hi IRQ ACTIVE LOW
gpio-90 ( |GPIO F1 ) in hi IRQ ACTIVE LOW
gpio-91 ( |GPIO F2 ) in hi IRQ ACTIVE LOW
gpio-204 ( |GPIO F3 ) in hi IRQ ACTIVE LOW
root@desk-mx6:~#
</pre>

The sysfs <code>/sys/class/leds/led[x]</code> entries can be listed:

<pre class="board-terminal">
root@desk-mx6:~# ls -la /sys/class/leds/led*
lrwxrwxrwx 1 root root 0 Jan 22 08:29 /sys/class/leds/led0 -> ../../devices/platform/leds/leds/led0
lrwxrwxrwx 1 root root 0 Jan 22 08:29 /sys/class/leds/led1 -> ../../devices/platform/leds/leds/led1
lrwxrwxrwx 1 root root 0 Jan 22 08:29 /sys/class/leds/led2 -> ../../devices/platform/leds/leds/led2
lrwxrwxrwx 1 root root 0 Jan 22 08:29 /sys/class/leds/led3 -> ../../devices/platform/leds/leds/led3
root@desk-mx6:~#
</pre>

==== Leds ON/OFF====
A userspace command can be issued for, using ''led1'' as an example, switching the led ON or OFF:

<pre class="board-terminal">
root@desk-mx6:~# echo 1 > /sys/class/leds/led1/brightness
root@desk-mx6:~# echo 0 > /sys/class/leds/led1/brightness
</pre>

==== Pushbutton input events ====
The userspace utility <code>evtest</code> can be used for detecting the user interaction:

<pre class="board-terminal">
root@desk-mx6:~# evtest /dev/input/event1
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio-push-button"
Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
Event code 59 (KEY_F1)
Event code 60 (KEY_F2)
Event code 61 (KEY_F3)
Event code 62 (KEY_F4)
Properties:
Testing ... (interrupt to exit)
Event: time 1705922290.536050, type 1 (EV_KEY), code 59 (KEY_F1), value 1
Event: time 1705922290.536050, -------------- SYN_REPORT ------------
Event: time 1705922290.733822, type 1 (EV_KEY), code 59 (KEY_F1), value 0
Event: time 1705922290.733822, -------------- SYN_REPORT ------------
Event: time 1705922292.632106, type 1 (EV_KEY), code 60 (KEY_F2), value 1
Event: time 1705922292.632106, -------------- SYN_REPORT ------------
Event: time 1705922292.868167, type 1 (EV_KEY), code 60 (KEY_F2), value 0
Event: time 1705922292.868167, -------------- SYN_REPORT ------------
Event: time 1705922293.389389, type 1 (EV_KEY), code 61 (KEY_F3), value 1
Event: time 1705922293.389389, -------------- SYN_REPORT ------------
Event: time 1705922293.581487, type 1 (EV_KEY), code 61 (KEY_F3), value 0
Event: time 1705922293.581487, -------------- SYN_REPORT ------------
Event: time 1705922293.995503, type 1 (EV_KEY), code 62 (KEY_F4), value 1
Event: time 1705922293.995503, -------------- SYN_REPORT ------------
Event: time 1705922294.153806, type 1 (EV_KEY), code 62 (KEY_F4), value 0
Event: time 1705922294.153806, -------------- SYN_REPORT ------------
</pre>
8,286
edits

Navigation menu