3.2.2.4. EQEP
Introduction
Linux has support for EQEP (Enhanced Quadature Encoder Pulse). EQEP channels can be used to interface with rotary encoder hardware.
AM64x SK: EQEP0: k3-am642-sk.dts
Kernel Configuration
Using menuconfig, enable the following driver:
Note
EQEP driver should be enabled by default as a kernel module in TI Linux kernel.
Features supported in TI SDK
position
overflow/underflow events
direction
unit timer
latched position
edge capture
Using eQEP with SYSFS interface
To check if eQEP is enabled with sysfs interface, check for the existance of the
following directory: /sys/bus/counter
and run the following command to find the
name of counter:
root@am62xx-evm:~# cd /sys/bus/counter/devices
root@am62xx-evm:/sys/bus/counter/devices# cat counter0/name
23200000.counter
root@am62xx-evm:/sys/bus/counter/devices#
The counter name shows this is eQEP0 at base adress 23200000.
Several sysfs attributes are generated by the Generic Counter interface, and reside under
the /sys/bus/counter/devices/counterX
directory, where X is to the respective counter
device id.
Please see the counter sysfs documentation upstream
or in TI Linux kernel /Documentation/ABI/testing/sysfs-bus-counter
for detailed information on each
generic counter interface sysfs attribute.
Through these sysfs attributes, programs and scripts may interact with the Generic Counter paradigm Counts, Signals, and Synapses of respective counter devices.
The following sysfs atributes can be found in /sys/bus/counter/devices/counterX
in TI SDK:
countY/ceiling
countY/count
countY/direction
countY/enable
countY/function
countY/latched_count
countY/signal0_action
countY/signal1_action
edge_capture_unit_enable
edge_capture_unit_latched_period
edge_capture_unit_max_period
edge_capture_unit_prescaler
latch_mode
unit_timer_enable
unit_timer_period
unit_timer_time
Character device nodes
Counter character device nodes are created under the /dev directory as counterX, where X is the respective counter device id.
$ ls /dev/counter*
/dev/counter0
Counter Events
Please read the generic counter API upstream or in
TI Linux kernel /Documentation/driver-api/generic-counter.rst
documentation to implement events:
Test eQEP on AM62x SK
AM62x SK & rotary encoder breakout board |
Example Diligent rotary encoder breakout board |
The example rotary encoder breakout board used in this example can be found here.
The following is an example for testing eQEP using sysfs interface:
root@am62xx-evm:~# echo 0xff > /sys/bus/counter/devices/counter0/count0/ceiling
root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/ceiling
255
root@am62xx-evm:~# echo 1 > /sys/bus/counter/devices/counter0/count0/enable
root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
0
root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
92
root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
148
root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
188
root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
252
root@am62xx-evm:~# cat /sys/bus/counter/devices/counter0/count0/count
12
Notice in this example that turning the rotary shaft encoder counterclockwise increases the count until reaching the ceiling, then wraps around to zero and starts again. Also, turning the rotary shaft encoder clockwise decreases the count.