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. Make sure the platform data and the platform device are above the platform declaration:

<pre>

<pre>

Line 37:

Line 37:

</pre>

</pre>

+

+

+

Also include: '&tct_hammer_led0' in the platform declaration

+

+

<pre>

+

static struct platform_device *tct_hammer_devices[] __initdata = {

+

&tct_hammer_led0,

+

&s3c_device_adc,

+

&s3c_device_wdt,

+

&s3c_device_i2c0,

+

&s3c_device_usb,

+

&s3c_device_rtc,

+

&s3c_device_usbgadget,

+

&s3c_device_sdi,

+

#ifdef CONFIG_MTD_PARTITIONS

+

&tct_hammer_device_nor,

+

#endif

+

};

+

</pre>

+

+

Now you can reflash the Kernel.

+

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.

+

== Nail Board LED's ==

−

== LED Hardware ==

+

<pre>

+

static struct s3c24xx_led_platdata tct_hammer_pdata_led1 = {

+

.gpio = S3C2410_GPH0,

+

.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,

+

.name = "led1",

+

.def_trigger = "timer",

+

};

−

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

+

static struct s3c24xx_led_platdata tct_hammer_pdata_led2 = {

+

.gpio = S3C2410_GPH1,

+

.flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,

+

.name = "led2",

+

.def_trigger = "timer",

+

};

+

+

+

static struct platform_device tct_hammer_led1 = {

+

.name = "s3c24xx_led",

+

.id = 1,

+

.dev = {

+

.platform_data = &tct_hammer_pdata_led1,

+

},

+

};

+

+

static struct platform_device tct_hammer_led2 = {

+

.name = "s3c24xx_led",

+

.id = 2,

+

.dev = {

+

.platform_data = &tct_hammer_pdata_led2,

+

},

+

};

+

</pre>

+

+

you will also need to add some gpio setup in the machine init function:

Latest revision as of 09:47, 14 May 2011

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. Make sure the platform data and the platform device are above the platform declaration: