Hammer LED Class Driver

From eLinux.org
Revision as of 15:16, 12 May 2008 by Prpplague (Talk | contribs) (Hammer LED Driver moved to Hammer LED Class Driver: this information is geared towards the LED Class driver)

Jump to: navigation, search

UserSpace Access

the LED onboard the hammer as well as the LED on the carrier board can be accessed from userspace via the sysfs interface. example interfaces are in /sys/devices/platform/s3c24xx_led.0/leds:led0/ and /sys/devices/platform/s3c24xx_led.1/leds:led1/. both directories include a file entry "brightness". to turn a LED on, echo a non zero value to the brightness file entry:

echo 1 > /sys/devices/platform/s3c24xx_led.0/leds:led0/brightness

to turn a LED off, echo a zero to the the brightness file entry:

echo 0 > /sys/devices/platform/s3c24xx_led.0/leds:led0/brightness

you can also check the current status of the LED by using cat on the brightness file entry:

cat /sys/devices/platform/s3c24xx_led.0/leds:led0/brightness

Adding New LEDS

a new LED connected via a GPIO can be defined in the linux-2.6.xx/arch/arm/mach-s3c2410/mach-tct_hammer.c file. each LED will need to include some platform data and a platform device definition:

static struct s3c24xx_led_platdata tct_hammer_pdata_led0 = {
	.gpio		= S3C2410_GPF0,
	.name		= "led0",
	.def_trigger	= "timer",

static struct platform_device tct_hammer_led0 = {
	.name		= "s3c24xx_led",
	.id		= 0,
	.dev		= {
		.platform_data = &tct_hammer_pdata_led0,

this uses the standard LEDS class in the main kernel tree. for additional information see the linux-2.6.xx/Documentation/leds-class.txt file.

LED Hardware

the most common way of operating a LED via a gpio is to use an active low configuration: