Input: rotary-encoder - convert documentation into to ReST format
This file require minimum adjustments to be a valid ReST file. Do it, in order to be able to parse it with Sphinx. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
committed by
Dmitry Torokhov
parent
7b11fdc39f
commit
42f2309bba
@@ -1,8 +1,11 @@
|
|||||||
|
============================================================
|
||||||
rotary-encoder - a generic driver for GPIO connected devices
|
rotary-encoder - a generic driver for GPIO connected devices
|
||||||
Daniel Mack <daniel@caiaq.de>, Feb 2009
|
============================================================
|
||||||
|
|
||||||
0. Function
|
:Author: Daniel Mack <daniel@caiaq.de>, Feb 2009
|
||||||
-----------
|
|
||||||
|
Function
|
||||||
|
--------
|
||||||
|
|
||||||
Rotary encoders are devices which are connected to the CPU or other
|
Rotary encoders are devices which are connected to the CPU or other
|
||||||
peripherals with two wires. The outputs are phase-shifted by 90 degrees
|
peripherals with two wires. The outputs are phase-shifted by 90 degrees
|
||||||
@@ -13,7 +16,7 @@ Some encoders have both outputs low in stable states, others also have
|
|||||||
a stable state with both outputs high (half-period mode) and some have
|
a stable state with both outputs high (half-period mode) and some have
|
||||||
a stable state in all steps (quarter-period mode).
|
a stable state in all steps (quarter-period mode).
|
||||||
|
|
||||||
The phase diagram of these two outputs look like this:
|
The phase diagram of these two outputs look like this::
|
||||||
|
|
||||||
_____ _____ _____
|
_____ _____ _____
|
||||||
| | | | | |
|
| | | | | |
|
||||||
@@ -40,8 +43,8 @@ For more information, please see
|
|||||||
https://en.wikipedia.org/wiki/Rotary_encoder
|
https://en.wikipedia.org/wiki/Rotary_encoder
|
||||||
|
|
||||||
|
|
||||||
1. Events / state machine
|
Events / state machine
|
||||||
-------------------------
|
----------------------
|
||||||
|
|
||||||
In half-period mode, state a) and c) above are used to determine the
|
In half-period mode, state a) and c) above are used to determine the
|
||||||
rotational direction based on the last stable state. Events are reported in
|
rotational direction based on the last stable state. Events are reported in
|
||||||
@@ -65,16 +68,16 @@ d) Falling edge on channel B, channel A in low state
|
|||||||
should have happened, unless it flipped back on half the way. The
|
should have happened, unless it flipped back on half the way. The
|
||||||
'armed' state tells us about that.
|
'armed' state tells us about that.
|
||||||
|
|
||||||
2. Platform requirements
|
Platform requirements
|
||||||
------------------------
|
---------------------
|
||||||
|
|
||||||
As there is no hardware dependent call in this driver, the platform it is
|
As there is no hardware dependent call in this driver, the platform it is
|
||||||
used with must support gpiolib. Another requirement is that IRQs must be
|
used with must support gpiolib. Another requirement is that IRQs must be
|
||||||
able to fire on both edges.
|
able to fire on both edges.
|
||||||
|
|
||||||
|
|
||||||
3. Board integration
|
Board integration
|
||||||
--------------------
|
-----------------
|
||||||
|
|
||||||
To use this driver in your system, register a platform_device with the
|
To use this driver in your system, register a platform_device with the
|
||||||
name 'rotary-encoder' and associate the IRQs and some specific platform
|
name 'rotary-encoder' and associate the IRQs and some specific platform
|
||||||
@@ -93,34 +96,33 @@ the configuration.
|
|||||||
Because GPIO to IRQ mapping is platform specific, this information must
|
Because GPIO to IRQ mapping is platform specific, this information must
|
||||||
be given in separately to the driver. See the example below.
|
be given in separately to the driver. See the example below.
|
||||||
|
|
||||||
---------<snip>---------
|
::
|
||||||
|
|
||||||
/* board support file example */
|
/* board support file example */
|
||||||
|
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <linux/rotary_encoder.h>
|
#include <linux/rotary_encoder.h>
|
||||||
|
|
||||||
#define GPIO_ROTARY_A 1
|
#define GPIO_ROTARY_A 1
|
||||||
#define GPIO_ROTARY_B 2
|
#define GPIO_ROTARY_B 2
|
||||||
|
|
||||||
static struct rotary_encoder_platform_data my_rotary_encoder_info = {
|
static struct rotary_encoder_platform_data my_rotary_encoder_info = {
|
||||||
.steps = 24,
|
.steps = 24,
|
||||||
.axis = ABS_X,
|
.axis = ABS_X,
|
||||||
.relative_axis = false,
|
.relative_axis = false,
|
||||||
.rollover = false,
|
.rollover = false,
|
||||||
.gpio_a = GPIO_ROTARY_A,
|
.gpio_a = GPIO_ROTARY_A,
|
||||||
.gpio_b = GPIO_ROTARY_B,
|
.gpio_b = GPIO_ROTARY_B,
|
||||||
.inverted_a = 0,
|
.inverted_a = 0,
|
||||||
.inverted_b = 0,
|
.inverted_b = 0,
|
||||||
.half_period = false,
|
.half_period = false,
|
||||||
.wakeup_source = false,
|
.wakeup_source = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct platform_device rotary_encoder_device = {
|
|
||||||
.name = "rotary-encoder",
|
|
||||||
.id = 0,
|
|
||||||
.dev = {
|
|
||||||
.platform_data = &my_rotary_encoder_info,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
static struct platform_device rotary_encoder_device = {
|
||||||
|
.name = "rotary-encoder",
|
||||||
|
.id = 0,
|
||||||
|
.dev = {
|
||||||
|
.platform_data = &my_rotary_encoder_info,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user