程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 6376|回复: 0
打印 上一主题 下一主题

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
& G' F2 i8 t3 [7 n- ?& ?. l* L2 {( i#include <linux/init.h>: [0 k4 X" S$ F: Q( m
#include <linux/module.h>
. N0 P; C. y# G! _: {& f$ m#include <linux/kernel.h>; B" x5 k7 i* D* }" T: y" X
#include <linux/types.h>
& R9 K* }. u4 [+ U#include <linux/gpio.h>
! {1 e0 }! M4 u9 A. h( H6 d. ?6 c#include <linux/leds.h>/ x3 K! v- [; X: k( L% w
#include <linux/platform_device.h>
* `  T* y7 j( o8 d9 W: ~+ N3 t
4 Q  x) P0 a! \9 P* Y: |0 g#include <asm/mach-types.h>
2 _! j! n! K. h3 |1 G  g' c#include <asm/mach/arch.h>6 n% @0 X8 [( F  O2 r# a; A7 d
#include <mach/da8xx.h>, G. h+ q/ r8 `# e( \; [
#include <mach/mux.h>
9 H; A# ~7 g6 s8 k
: {- \8 X0 S2 B2 X: S#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
. o2 i. I" G) ~7 e#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
/ _/ O6 E# N9 z  ~#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)- k) c, X( x/ ]9 z$ Q( O2 y
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# x3 O6 F: W" H( E, l; Z4 {: l( X: g$ r5 p
/* assign the tl som board LED-GPIOs*/
; _# Y/ D! g1 u7 i0 c2 Sstatic const short da850_evm_tl_user_led_pins[] = {4 p/ y# E, b5 a
        /* These pins are definition at <mach/mux.h> file */+ i' _! w& z- e# F: Y9 i. D7 z
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# x$ O% B9 s* y% E' y' l; n* T8 r
        -1: A' b3 m- \4 |* x
};, Z: q/ {8 X  B! S

5 v5 ^9 K. ~7 jstatic struct gpio_led da850_evm_tl_leds[] = {" d5 A% l9 `! c; d
        {
( p7 V7 j. R! P                .active_low = 0,7 @/ |* `; t) I+ ~( ?% r  x8 q
                .gpio = DA850_USER_LED0,* D- ~2 d' F2 S6 A8 K0 J  n
                .name = "user_led0",
0 ]  @% x* L/ V                .default_trigger = "default-on",
& [+ ?& k% b9 r2 p3 q# X8 h; ^        },
7 I7 Q+ m5 b, L        {
5 D4 R; @$ X& Z% X                .active_low = 0,
$ u% _; L$ F. o5 l" [2 B& b2 z                .gpio = DA850_USER_LED1,( b/ C$ G1 P8 @4 w( l& O
                .name = "user_led1",
! ^3 ^0 Q7 y3 v* G9 P' b4 l* Q                .default_trigger = "default-on",) f8 U) Z* A& w; S
        },
- m  K' Z! b, r2 G3 V% ^" l- F) `1 z0 z        {) ^4 }" w1 M% T: K. \# i* s
                .active_low = 0,
- c+ H6 S. m( W                .gpio = DA850_USER_LED2,
( g( M6 E, V( N2 I1 W& Y# h                .name = "user_led2",
: u' t( F% y! d( z* j; J: D3 E% V; O* C                .default_trigger = "default-on",
! l5 b; C$ V9 ~6 V! M$ l; o; D        },$ X4 N1 S5 @# s" o$ N
        {# |, w0 \0 O* p( e) O, X$ M
                .active_low = 0,) m. V. l- g* d- u6 m
                .gpio = DA850_USER_LED3,0 k& F, r2 \  O6 S5 L+ J, W: {
                .name = "user_led3",7 {5 ~4 g/ @8 ]; n  y1 i1 h& ]: U& i
                .default_trigger = "default-on",
, D, l+ T% V0 b' U        },0 G8 S! X8 C( j/ x7 A) W5 C
};: r0 l, ^( v7 O5 V- P1 V+ d' h! M8 |

% T* |8 a! D" x2 y" j+ p7 j3 [1 h, lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 b! h1 @# ]. o& G  q$ {
        .leds = da850_evm_tl_leds,# }) ?, i. N3 V! v
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; }/ y3 B  q, @7 e) M& o4 m
};
) Q' ~1 [6 s& W8 Z
1 M$ z( @  K1 a7 \) Lstatic void led_dev_release(struct device *dev)
0 ^$ [0 t0 W$ W6 T{
$ U1 i- f6 J5 v1 C};
; ^, ]) ?; Q2 h+ [
  r! D3 x2 ]3 Lstatic struct platform_device da850_evm_tl_leds_device = {
4 D( x( W$ x2 s% ]' A" k        .name                = "leds-gpio",) N! [2 Q% b$ X: J
        .id                = 1,
( r. t8 P: ^2 c8 Z5 g/ d$ S        .dev = {
* h2 ?; C2 i8 u+ |1 u                .platform_data = &da850_evm_tl_leds_pdata,
$ G! g4 N  r# [! i/ h                .release = led_dev_release,) Q& J* K) Z2 Q% a: b" W
        }
; m4 \  B* I" u; I, R4 A' E};
% p5 L8 k' ^; [5 F3 k
: X* s+ A! ?& a+ y: _static int __init led_platform_init(void)0 }! I; c, B7 W$ ?; p4 T
{
4 \9 O6 q$ P2 w# J        int ret;
4 E3 V- P3 F7 n8 W4 v$ ]/ A1 c$ t#if 0
7 H5 T- w4 `4 J# L$ a+ X, X        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! c+ q* h# {& Z! n        if (ret)& |+ g% U1 D* S7 ~/ M  i8 D
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
! {/ F& z# ^# g' G                                "%d\n", ret);
0 `/ a% }. D7 j% N$ Q/ q  x#endif7 K& Y- ]2 g+ c% l, b+ ]
        ret = platform_device_register(&da850_evm_tl_leds_device);
6 D) M" b$ t$ |& i1 j- m: q        if (ret)% _/ z. k. B5 z  [/ Z* Z8 b) f
                pr_warning("Could not register som GPIO expander LEDS");6 A6 l. q  o; m3 `
        else' o- v/ a2 S$ ^8 B: J
                printk(KERN_INFO "LED register sucessful!\n");
* X. ?; T- M) o9 b9 I& D& u( M& J* }+ l/ S
        return ret;
7 F; `; W: I! P}+ M; a- Y4 ^% l" Y5 D

. y9 k/ w6 k5 nstatic void __exit led_platform_exit(void)0 k3 w0 x! T1 c. j$ r4 U. H
{. K$ h0 F0 y; C
        platform_device_unregister(&da850_evm_tl_leds_device);. [3 a! d! \6 w3 j: p/ M
8 T7 d# {! H- f0 a
        printk(KERN_INFO "LED unregister!\n");
7 _8 Z8 C, T3 U}
& A6 }' W* k' b+ A! S0 u
/ I& ?; p+ }3 \3 T$ z7 {- h# y; bmodule_init(led_platform_init);+ `6 ?5 o) \0 C: N
module_exit(led_platform_exit);: o4 g# w4 A9 x

' P7 |: ^4 R% ^9 c- KMODULE_DESCRIPTION("Led platform driver");2 s+ c$ k' i" |, z- ~8 v* x
MODULE_AUTHOR("Tronlong");- ^6 m1 ?% x- E' n" V7 E
MODULE_LICENSE("GPL");
+ r" f' E5 n* p' j( M  X1 K' s( k" l; L2 S* `6 M4 X) w- \+ r
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2025-11-19 20:35 , Processed in 0.038505 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

快速回复 返回顶部 返回列表