Difference between revisions of "Hammer LED Class Driver"

From eLinux.org
Jump to: navigation, search
 
Line 19: Line 19:
  
 
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:
 
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:
 
+
<nowiki>
 
static struct s3c24xx_led_platdata tct_hammer_pdata_led0 = {
 
static struct s3c24xx_led_platdata tct_hammer_pdata_led0 = {
 
.gpio = S3C2410_GPF0,
 
.gpio = S3C2410_GPF0,
Line 34: Line 34:
 
},
 
},
 
};
 
};
 
+
</nowiki>
 
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.
 
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.

Revision as of 07:30, 29 January 2008

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/class/leds/led0/ and /sys/class/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/class/leds/led0/brightness

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

echo 0 > /sys/class/leds/led0/brightness


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

cat /sys/class/leds/led0/brightness


Defining

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, .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, .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.