Rotary encoder with GPIOs: Difference between revisions
From ArmadeusWiki
(Created page with "{{Under_Construction}} =Introduction= This page will explain you how to drive a rotary encoder connected to GPIOs of your APF/OPOS. =Hardware= The instructions were tested o...") |
|||
Line 6: | Line 6: | ||
=Hardware= | =Hardware= | ||
The instructions were tested on [[OPOS6ULDev]] where rotary encoder is connected to GPIOs on RPi compatible connector: | The instructions were tested on [[OPOS6ULDev]] where rotary encoder is connected to GPIOs on RPi compatible connector: | ||
{| border="1" cellpadding="5" cellspacing="0" summary="Restart of NFS server depending on your distribution" | |||
+ || 1 | |- style="background:#efefef;" | ||
GND || 6 | ! Encoder !! Pin number <br>on RPi connector !! Function | ||
SW || | |- | ||
DT 32 || | | + || 1 || Power | ||
CLK 40 || | |- | ||
| GND || 6 || GND | |||
|- | |||
| SW || || Key press | |||
|- | |||
| DT || 32 || | |||
|- | |||
| CLK || 40 || | |||
|} | |||
=Software= | =Software= |
Revision as of 18:17, 3 March 2017
Page under construction...
Informations on this page are not guaranteed !!
Introduction
This page will explain you how to drive a rotary encoder connected to GPIOs of your APF/OPOS.
Hardware
The instructions were tested on OPOS6ULDev where rotary encoder is connected to GPIOs on RPi compatible connector:
Encoder | Pin number on RPi connector |
Function |
---|---|---|
+ | 1 | Power |
GND | 6 | GND |
SW | Key press | |
DT | 32 | |
CLK | 40 |
Software
Device Tree need to be adapted:
gpio-keys {
compatible = "gpio-keys";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpio_keys>;
user-button {
label = "User button";
gpios = <&gpio2 11 GPIO_ACTIVE_LOW>;
linux,code = <BTN_MISC>;
wakeup-source;
};
+ rotary1_button {
+ label = "rotary1_button";
+ gpios = <&gpio5 2 GPIO_ACTIVE_LOW>;
+ debounce-interval = <10>;
+ linux,code = <28>;
+ };
}
+ rotary1 {
+ compatible = "rotary-encoder";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_rotary1>;
+ gpios = <&gpio5 0 1>, <&gpio5 1 1>;
+ linux,axis = <1>; /* REL_Y */
+ rotary-encoder,relative-axis;
+ };
...
&iomuxc {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_gpios>;
...
+ pinctrl_rotary1: rotary1grp {
+ fsl,pins = <
+ MX6UL_PAD_SNVS_TAMPER0__GPIO5_IO00 0x0b0b0
+ MX6UL_PAD_SNVS_TAMPER1__GPIO5_IO01 0x0b0b0
+ >;
+ };
...