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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
6 a, Y0 l8 j/ z- C#include <linux/init.h>
" `3 ?8 j( ?, q3 O3 i#include <linux/module.h>. l8 w% D- @3 [5 Z, o8 h
#include <linux/kernel.h>% g' k9 r# Q# a1 a  B* r6 H, m% |# h
#include <linux/types.h>
, V- ?) H1 ~; G+ r#include <linux/gpio.h>
, w; V$ q) o* e& y' m& v#include <linux/leds.h>
3 ~. U! \9 c1 S/ B1 }8 T& f! x7 D, @#include <linux/platform_device.h>
- u. Q; ^2 X: E2 P
5 z4 R8 {, }0 ?0 C3 H  ?#include <asm/mach-types.h>9 f( q" F8 l8 Y, n8 q" c
#include <asm/mach/arch.h>/ ~# }* ^9 @1 v9 B8 f$ f& C& G
#include <mach/da8xx.h>
$ s" U4 u* o( I#include <mach/mux.h>  [. z7 w1 e  X/ r3 m6 s3 |0 Y. l* f

6 U/ a% D9 D- A& h, B. z9 I! U#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
$ b" G! _/ U1 Y1 }#define DA850_USER_LED1        GPIO_TO_PIN(0, 5). U% V! r* m8 T
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 q; O$ b5 \) T3 y' s/ ^. k2 q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)- E! Q+ w  ^' g4 A. s

* l. h' G$ l8 \% b" W/* assign the tl som board LED-GPIOs*/8 u; F4 H/ c9 @8 I! c
static const short da850_evm_tl_user_led_pins[] = {! L. @8 R' e' @! u
        /* These pins are definition at <mach/mux.h> file */
2 B1 S) H) N" A$ z+ s* g        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! D; p& N! ?+ o, w        -1
0 M- q% J6 C6 w" ^};9 k, g3 |) R4 V2 G! A7 s# e4 _
) w9 X  f, a2 e+ ^
static struct gpio_led da850_evm_tl_leds[] = {
5 _; p( ]5 I2 S5 x        {, G; K: c3 X' ~3 _+ Y
                .active_low = 0,
6 r9 {8 e7 Q0 i% A4 T                .gpio = DA850_USER_LED0,2 J! Y0 L7 {1 D. L  q9 p. v% f7 P. o0 x9 @
                .name = "user_led0",# C' U; s) g6 ^* S4 f& J
                .default_trigger = "default-on",3 m5 }1 Z* ]1 L1 `: w
        },
9 E5 ^% Z& d$ `0 C        {
8 N* r$ A2 \- u7 u  Y+ R                .active_low = 0,
! \1 Z3 d4 e: q* u                .gpio = DA850_USER_LED1,
5 J3 t* Z4 y+ O- Y                .name = "user_led1",: r: J" Y3 o3 r; P2 A! X  ?2 M
                .default_trigger = "default-on",
3 M1 g: T' O0 m: u        },
) `7 f& D& q7 X( Q2 j        {3 e1 o! F3 X2 `) S2 `; U4 T: Y/ s
                .active_low = 0,
" c+ `! Q* y& n                .gpio = DA850_USER_LED2,/ X6 a- t- x2 \  a! J' w2 }; C
                .name = "user_led2",  d! V' [! i# H3 u3 @" ?* }
                .default_trigger = "default-on",& X' D- J* D) V
        },! X& e! k+ g1 E9 u& t$ v# i8 }
        {/ l1 r' I) y( a( w
                .active_low = 0,4 I6 |2 g4 c% z% _
                .gpio = DA850_USER_LED3,
+ h9 v0 i( n% z1 x% B' d$ r2 U% M! A                .name = "user_led3",* c4 o5 {. E, l1 ~
                .default_trigger = "default-on",
1 L2 h. K7 l1 ^2 s% a' a  T        },
( d' Q/ g1 \3 p- A5 }};
' R+ N1 l/ H; V4 p5 [8 }
/ A- s, I, c! N% N  _4 lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! ~5 |, B! Z3 `; f* _9 h
        .leds = da850_evm_tl_leds,
4 m6 Z0 r* V8 t" B7 ~        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 F4 W6 p2 r" W, p3 \0 `, B/ i5 L};% i  f" h# z# l. j
7 M" n; n) s, L
static void led_dev_release(struct device *dev)
7 o) C* Y0 ~) G: _{& S1 N, I: ?" k- ^9 }. E
};9 [" H& x/ F* i; a4 P4 ]% u5 ~

) ^) N/ \8 t! `) c* Fstatic struct platform_device da850_evm_tl_leds_device = {
8 L4 _/ M! m' `* `0 k$ g        .name                = "leds-gpio",& N2 F# @- X0 D# t# ?$ [/ t
        .id                = 1," J+ O9 {- X5 K5 t
        .dev = {3 Y* }3 w- X3 A& H
                .platform_data = &da850_evm_tl_leds_pdata,  q+ x9 J3 c0 H4 M4 V: C
                .release = led_dev_release,3 ]; A; a7 A+ g3 O3 _+ C4 F6 ^
        }6 w( l9 T3 L' Y% t
};! Z" t  h, E" y( D9 i- d

* r) I. m6 x9 Qstatic int __init led_platform_init(void)
# f: o4 w" C! l. J{" Z; S  F+ X$ b2 ?. @5 L0 {5 W" U. y
        int ret;
4 B( p, x$ h+ O8 J  Y  f#if 08 p6 h6 j  S/ W! c# ^  z- k- p
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 H1 A# B, T  B3 w% P( k
        if (ret): J4 v  [+ p9 E/ w6 U
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ a/ p7 Z+ ~2 a- F; n1 \% J
                                "%d\n", ret);
; c( M* e. p+ W3 X) q- n#endif! C- L% w" H0 G$ N2 H
        ret = platform_device_register(&da850_evm_tl_leds_device);/ f& f- K: o; `! i/ ?# \9 j" d
        if (ret)
9 {% J0 y( d9 P                pr_warning("Could not register som GPIO expander LEDS");: {* Y& j) d0 w6 v
        else. J- h6 u8 |9 s6 _
                printk(KERN_INFO "LED register sucessful!\n");
: M  d; H& M2 A- B, t4 K% G1 }! i! j2 ~
        return ret;
8 k+ Y2 f6 v# O4 ]. {/ R8 L}
; Q2 ]9 [) K& C1 @& x- v
) Q4 F) N+ K9 S5 g& Wstatic void __exit led_platform_exit(void)
7 w$ c* r( H$ Q3 l5 m{  y, S3 {' @# s- R) M/ ]
        platform_device_unregister(&da850_evm_tl_leds_device);% a" Y) m4 x+ o' o; H; D

$ ]' |: Q6 z: K3 p4 E9 E        printk(KERN_INFO "LED unregister!\n");3 a; }, O  Y$ j5 M4 ]
}
4 g; h/ F* w4 J% `$ a% T0 E1 g( @9 I
module_init(led_platform_init);
( ]+ A1 Y8 \. |module_exit(led_platform_exit);
1 y8 [) u9 j. l% }" E) J
& ^; }5 p6 d( K& IMODULE_DESCRIPTION("Led platform driver");
$ j2 ^% Q" L0 F  O' N3 K* o1 hMODULE_AUTHOR("Tronlong");  U  l3 K- L: N, F$ Y
MODULE_LICENSE("GPL");
" ]0 @+ Z7 H' K9 K7 W8 T3 Z9 k
8 C( k+ v) f' t4 g* J6 a+ R3 h
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-11 08:54 , Processed in 0.038967 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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