sakoman.com

How to use the buttons on OMAP development boards PDF Print E-mail

Beagle, Overo, and Panda all have push buttons that are connected to GPIO pins.  Overo has 2 buttons, Beagle and Panda each have a single button.

The kernels for these boards implement the kernel gpio-keys feature, which makes button press events available through the linux input system. These state changes are tied to standard input events and can be monitored by reading /dev/input/by-path/platform-gpio-keys-event.  The default setup returns the standard codes BTN_0 and BTN_1 on Overo, and BTN_0 for Beagle and Panda.  These codes are defined in /include/linux./input.h

You can easily test this functionality using the evtest utility, which is included in the GNOME image.  The evtest utility takes the raw events being reported on /dev/input/by-path/platform-gpio-keys-event and prints them in a human friendly form.

The following command will report state changes on the button(s) set up with gpio-keys.  For this example, we will use Overo, which has two buttons set up. To start the monitoring:

# evtest  /dev/input/by-path/platform-gpio-keys-event 
Input driver version is 1.0.0

Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio-keys"
Supported events:
Event type 0 (Sync)
Event type 1 (Key)
Event code 256 (Btn0)
Event code 257 (Btn1)
Testing ... (interrupt to exit)

Nothing further will be printed until we press a button.  Let's start with the first button (labeled gpio23):

Event: time 1293485115.917332, type 1 (Key), code 256 (Btn0), value 0
Event: time 1293485115.917332, -------------- Report Sync ------------
Event: time 1293485116.156643, type 1 (Key), code 256 (Btn0), value 1
Event: time 1293485116.156643, -------------- Report Sync ------------

We see that events are report for both the button press and the button release.  And then pressing the second button (labeled gpio14):

Event: time 1293486786.146955, type 1 (Key), code 257 (Btn1), value 0
Event: time 1293486786.146955, -------------- Report Sync ------------
Event: time 1293486786.154675, type 1 (Key), code 257 (Btn1), value 1
Event: time 1293486786.154675, -------------- Report Sync ------------

Of course you can also monitor the raw data stream from /dev/input/by-path/platform-gpio-keys-event. The events are 16 bytes in length, so using hexdump to view them makes it relatively easy to interpret:

# hexdump /dev/input/by-path/platform-gpio-keys-event

Pressing the first button yeilds:

0000000 0fda 4d19 9553 0000 0001 0100 0000 0000
0000010 0fda 4d19 9571 0000 0000 0000 0000 0000
0000020 0fda 4d19 183e 0003 0001 0100 0001 0000
0000030 0fda 4d19 183e 0003 0000 0000 0000 0000

And pressing the second button:

0000040 0fde 4d19 a24e 0000 0001 0101 0000 0000
0000050 0fde 4d19 a24e 0000 0000 0000 0000 0000
0000060 0fde 4d19 89d0 0002 0001 0101 0001 0000
0000070 0fde 4d19 89d0 0002 0000 0000 0000 0000

Tags: Beagle Overo Panda How to
Last Updated on Friday, 31 December 2010 07:43
 

0 Comments

Add Comment


     

    You are here  : Home

    Advertisement

    Advertisement