Difference between revisions of "PandaBoard Button"

From eLinux.org
Jump to: navigation, search
(Created page with "== UserSpace Access == the carrier board push button can be accessed via the sysfs interface as well as a shell script functionality. the sysfs entry for the push button can be ...")
 
(Adding New PushButtons)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== UserSpace Access ==
 
== UserSpace Access ==
  
the carrier board push button can be accessed via the sysfs interface as well as a shell script functionality. the sysfs entry for the push button can be found in the directory mark /sys/devices/platform/gpio-keys.0 . the driver also looks for a shell script in /sbin called pb0.sh. this shell script can be used to start user land applications. here is the provided example shell script:
+
the push button can be accessed via the sysfs interface as well as a shell script functionality. the sysfs entry for the push button can be found in the directory marked /sys/devices/platform/ . each button will be listed as gpio-keys follow by a number.
 
 
<pre>
 
#!/bin/sh
 
 
 
if [ $1 = "down" ] ; then
 
    if [ -x /mnt/flash/scripts/pb0.down ] ; then
 
        /mnt/flash/scripts/pb0.down
 
    else
 
        current=`cat /sys/class/leds/led1/brightness`
 
        if [ "${current}" = 0 ] ; then
 
            echo 1 > /sys/class/leds/led1/brightness
 
        else
 
            echo 0 > /sys/class/leds/led1/brightness
 
        fi
 
    fi
 
else
 
    if [ -x /mnt/flash/scripts/pb0.up ] ; then
 
        /mnt/flash/scripts/pb0.up
 
    fi
 
fi#
 
</pre>
 
 
 
  
 
== Adding New PushButtons ==
 
== Adding New PushButtons ==
  
the gpio buttons are defined in the linux-2.6.xx/arch/arm/mach-s3c2410/mach-tct_hammer.c file. each button requires that the gpio be defined, a name, and key scan code associated with it. in addition standard platform data and platform device have to be defined.
+
the gpio buttons are defined in the linux kernel machine file. in this case for pandaboard it would be in  arch/arm/mach-omap2/board-omap4panda.c file. each button requires that the gpio be defined, a name, and key scan code associated with it. in addition standard platform data and platform device have to be defined.
  
 
<pre>
 
<pre>
Line 33: Line 11:
 
     [0] = {
 
     [0] = {
 
             .code     = 0x26,
 
             .code     = 0x26,
             .gpio          = S3C2410_GPG3,
+
             .gpio          = 39,
 
             .active_low    = 0,
 
             .active_low    = 0,
 
             .desc          = "PB0",
 
             .desc          = "PB0",
Line 44: Line 22:
 
};
 
};
 
 
static struct platform_device tct_hammer_buttons = {
+
static struct platform_device pandaboard_buttons = {
 
.name = "gpio-keys",
 
.name = "gpio-keys",
 
.id = 0,
 
.id = 0,
Line 52: Line 30:
 
};
 
};
 
</pre>
 
</pre>
 
 
  
 
== PushButton Hardware ==
 
== PushButton Hardware ==
  
[[Image:pb-example.jpg]]
+
[[Image:pb-example-1v8.jpg]]
  
 
[[Category:PandaBoard]]
 
[[Category:PandaBoard]]

Latest revision as of 11:42, 9 April 2012

UserSpace Access

the push button can be accessed via the sysfs interface as well as a shell script functionality. the sysfs entry for the push button can be found in the directory marked /sys/devices/platform/ . each button will be listed as gpio-keys follow by a number.

Adding New PushButtons

the gpio buttons are defined in the linux kernel machine file. in this case for pandaboard it would be in arch/arm/mach-omap2/board-omap4panda.c file. each button requires that the gpio be defined, a name, and key scan code associated with it. in addition standard platform data and platform device have to be defined.

static struct gpio_keys_button gpio_keys_buttons[] = {
    [0] = {
            .code	    = 0x26,
            .gpio           = 39,
            .active_low     = 0,
            .desc           = "PB0",
    },
};

static struct gpio_keys_platform_data gpio_keys_data = {
	    .buttons   = gpio_keys_buttons,
    	    .nbuttons   = ARRAY_SIZE(gpio_keys_buttons),
};
											
static struct platform_device pandaboard_buttons = {
	.name		= "gpio-keys",
	.id		= 0,
	.dev		= {
		.platform_data = &gpio_keys_data,
	},
};

PushButton Hardware

Pb-example-1v8.jpg