LED_9261在linux2.6.30中tick_led的实现

在linux2.6.30内核中,内核也提供了相关的平台驱动来操作gpio或LED,但更简便的方法是直接操作GPIO来控制led。

网上一博文中介绍直接封装led_on和led_off()函数直接调用即可。

void led1_on() {  

    s3c_gpio_cfgpin(LED_ID1, S3C_GPIO_OUTPUT);  

    s3c_gpio_setpull(LED_ID1, S3C_GPIO_PULL_NONE);  

    gpio_set_value(LED_ID1, 1);  

}  

void led1_off() {  

    s3c_gpio_cfgpin(LED_ID1, S3C_GPIO_OUTPUT);  

    s3c_gpio_setpull(LED_ID1, S3C_GPIO_PULL_NONE);  

    gpio_set_value(LED_ID1, 0);  

}  

2.6.30内核中9261中实现tick led功能,可在板卡文件中添加LED gpio初始化,之后在时钟中断中添加led闪烁功能即可,具体分析如下:

>>板卡文件中初始化led gpio。

at91_init_leds(0, AT91_PIN_PA11);

进一步追踪此函数,就是设置此gpio为输出,并初始化为高或低电平。

>>在时钟中断函数at91sam926x_pit_interrupt()中,增加tick led闪烁功能。

static inline void do_leds(void)

{

    static unsigned int count = HZ/2;

    if (--count == 0) {

        count = HZ/2;

        leds_event(led_timer);

    }  

}

>>leds_event()在leds_init()中初始化,

__initcall(leds_init);

其在系统初始化时设置。

进一步追踪:leds_event(led_timer);<==> at91_led_toggle(AT91_PIN_PA11);

至此tick led功能实现。

参考:

  1. http://blog.csdn.net/hellowxwworld/article/details/11001739
原文地址:https://www.cnblogs.com/embedded-linux/p/6012854.html