通過修改bsp向系統增加LED驅動 的方法

來源:互聯網
上載者:User

參考ldd6410-manual[1].pdf

向s3c6410系統曾加LED裝置的驅動.有四個led 的燈分別與GPIO 的GPK4,GPK5,GPK6,GPK7相連,四個led為共陽。

Linux 核心下的drivers/leds/ledsgpio.c 實現了一個體繫結構無關的 GPIO LED 驅動, 使用此 LED 驅動,開發人員不需要修改一行代碼,只需要在BSP的板檔案(/home/wsh/s3c-linux-2.6.28.6-Real6410/arch/arm/mach-s3c6410/mach-smdk6410.c)中定義相關的平台的裝置和資料。

 

///*led driver support*/
static struct gpio_led s3c6410_leds[] = {
[0] = {
     .name = "LED10",
  .gpio = S3C64XX_GPK(4),
   },
[1] = {
  .name = "LED12",
  .gpio = S3C64XX_GPK(5),
   },
[2] = {
  .name = "LED13",
  .gpio = S3C64XX_GPK(6),
   },
[3] = {
  .name = "LED14",
  .gpio = S3C64XX_GPK(7),
  },
};

/*platform data support 其中gpio_led_platform_data在/linux/leds.h中定義了應將此檔案包含在bsp檔案當中*/

static struct gpio_led_platform_data s3c6410_gpio_led_pdata = {
 .num_leds = ARRAY_SIZE(s3c6410_leds),
 .leds = s3c6410_leds,
};

/*platform device struct  in /linux/platform_device.h define */

static struct platform_device s3c_device_led = {
 .name = "leds-gpio",//註冊device name 要於加進去的裝置驅動一致,不一致就註冊不成功
 .id   = 1,
 .dev  = {
        .platform_data = &s3c6410_gpio_led_pdata,
     },
     };

並將“&s3c_device_led,”語句填入 struct platform_device *smdk6410_devices[]數組,作為該數組的一個成
員。

編譯核心make menuconfig

時會應選擇

 --- LED Support                                                               │ │ 
  │ │        <*>   LED Class Support                                                       │ │ 
  │ │              *** LED drivers ***                                                     │ │ 
  │ │        < >   LED driver for PCA9532 dimmer                                           │ │ 
  │ │        <*>   LED Support for GPIO connected LEDs                                     │ │ 
  │ │        < >   LED Support for PCA955x I2C chips                                       │ │ 
  │ │              *** LED Triggers ***                                                    │ │ 
  │ │        [ ]   LED Trigger support   

通過以下方式能查看系統的驅動

在系統列印的時候會列印如下資訊

Registered led device: LED10
Registered led device: LED12
Registered led device: LED13
Registered led device: LED13

[root@FriendlyARM leds]# pwd
/sys/class/leds
[root@FriendlyARM leds]# ls
LED10  LED12  LED13  LED14  mmc0

控制燈亮

[root@FriendlyARM leds]# echo 0 >LED10/brightness

控制燈滅

[root@FriendlyARM leds]# echo 1 >LED10/brightness

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.