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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
( I" M8 m0 R4 q1 q5 p1 n# b' G#include <linux/init.h>' ~  v$ B* a' ?6 j# c1 E
#include <linux/module.h>: ^( z4 T" m- _! W+ a! q3 m! b
#include <linux/kernel.h>; @6 |+ T. _( q( D0 C- w4 o6 `
#include <linux/types.h>
, e9 d6 Q- q, t- ^#include <linux/gpio.h>" \) S  ^- S# C- @" T( H' o
#include <linux/leds.h>2 k- N: G1 i' G, k) G% w
#include <linux/platform_device.h>+ _) s& ]  `5 @- v

; Q: c% P: p  l/ ^! [- w& N#include <asm/mach-types.h>) U- V$ n, b% C. c2 \  b" A1 G
#include <asm/mach/arch.h>
1 \$ r( ]5 D! [* ?4 i#include <mach/da8xx.h>
8 s" D. n( u5 c! @+ I1 o. ~  u#include <mach/mux.h>- H! g6 s9 U$ V; y1 X3 e) z' p2 n! M
8 o5 y6 K( l; Z1 M4 d8 C
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)% c+ r& W4 s3 r+ B) u& P
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
; \( Z) D% ^4 ^; n+ f9 l. v, h#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
- E+ _$ |) R7 e5 j" D3 }! e% v#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
  r$ U" P4 u' B# b$ {/ b% {
6 A9 ]" n* y0 b6 R/* assign the tl som board LED-GPIOs*/: c# C2 R0 D' u1 R* ?: p
static const short da850_evm_tl_user_led_pins[] = {" z# }$ Y- I( l$ t9 G3 {- C
        /* These pins are definition at <mach/mux.h> file */
% }& R; F8 J6 ~* O$ `# C0 m$ G7 Q1 N  M        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 r5 X/ n5 o* j. Y
        -1! }6 e; |" {" i4 {
};
  {0 i$ P- m/ U2 v. k2 `
/ V/ Q- y# D, i9 t7 G0 {! Estatic struct gpio_led da850_evm_tl_leds[] = {4 A. O. i' d, m  k; E% T
        {/ F9 t% X) X7 d: ^) \
                .active_low = 0,7 b: A2 R& Y/ m8 }$ R8 u+ E' @
                .gpio = DA850_USER_LED0,
! V8 G+ k# ~: @! w. U5 T                .name = "user_led0",' {/ E+ B1 @# w
                .default_trigger = "default-on",5 c# f4 V9 v' ]% e) S2 n
        },
1 Z) B! K" h6 ~! g: j        {$ N! {$ Y' f3 N+ R* y4 f
                .active_low = 0,' {: k& z. ?8 H
                .gpio = DA850_USER_LED1,
) c: c7 H4 w' W, M; F- T                .name = "user_led1",
3 g+ o# i( o8 a0 l  Y: P3 w                .default_trigger = "default-on",6 N8 Y/ `4 w# e
        },0 X# s5 b, u, R  t
        {- r. Q" j4 {6 s( F
                .active_low = 0,
" n/ S. c. F8 I5 L9 F                .gpio = DA850_USER_LED2,
5 Q& w; z  K2 j# q                .name = "user_led2",& l/ i8 O0 O3 S4 w( ^( g, |  T; R
                .default_trigger = "default-on",. ~  p  _. |5 ~+ o! s
        },
1 I6 G% z: x3 ~/ G  A' E1 w        {, H3 Y7 o. u; p5 f' A
                .active_low = 0,$ R: G6 R: `  q0 u
                .gpio = DA850_USER_LED3,
, Y3 B& v  ~: G6 H$ Y                .name = "user_led3",
7 [7 }, ~. X" T9 f8 ]                .default_trigger = "default-on",
  E: A& V1 Z, `: h7 ?        },
7 ]* ~* ~6 t. R" X% H2 o};# |) i$ P2 b3 a5 k5 g8 u# T( P
! n/ K6 q( U0 t( E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( k: b5 z  _7 m. c) s/ V0 r1 @9 Y        .leds = da850_evm_tl_leds,+ g0 U  n2 a! U# G1 N+ ^% Z
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: A7 f9 G1 L2 H7 f6 v
};
' w- M/ b; J8 Q
$ r2 c* P% f7 @+ Q9 `$ B/ Bstatic void led_dev_release(struct device *dev)" s/ x. h# z$ g* ~$ w) V
{: F  {. D6 g2 n" [- L
};
$ l  C% v1 O$ g, G8 n( x( B3 G$ w. s- C# E9 M
static struct platform_device da850_evm_tl_leds_device = {
# Z9 |2 i" e8 A; k2 V        .name                = "leds-gpio",
' [5 K2 ?( \, L0 \( i" j" P, `        .id                = 1,, O* |2 n. x& z! j; c
        .dev = {/ S4 k" J$ t/ r( q; }- g9 M3 q, [8 u
                .platform_data = &da850_evm_tl_leds_pdata,
, @$ \% |4 h/ X( z9 b. z                .release = led_dev_release,
2 P  Z' o: D, A8 R, {        }$ F& |) y+ L! j* t7 r
};
5 H# A( e5 x# V" s4 c$ u
/ N. k0 s7 k) K( W! Q+ r9 I* G# O  Mstatic int __init led_platform_init(void)( \8 L! \4 d# z1 v
{
) C' P& g/ o+ ~7 I* K; M: ?' D        int ret;
  Q* M; c! ~1 J% }3 B" o+ }! W9 |#if 08 w  F  @# U% Y& ?3 L
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 y1 }0 c! P' G4 B6 a0 ~
        if (ret)2 o" U4 ^- a  K" h) o7 D
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ e  n2 s9 L0 }; G                                "%d\n", ret);7 [+ i3 W$ g$ Z7 }" |- n0 V- O5 o
#endif
  C" i6 W, h+ \" {! y8 R, Q- A* p        ret = platform_device_register(&da850_evm_tl_leds_device);
1 r7 v7 _+ K9 S1 b/ F; B9 W& W        if (ret)
' y& ]& t0 R& i' S/ S4 v, t. D                pr_warning("Could not register som GPIO expander LEDS");2 V2 g( K+ i# j2 @
        else6 E# ^) m. F+ a$ \% }$ ]
                printk(KERN_INFO "LED register sucessful!\n");
4 V) J& P; W; C- b0 g
% f& @# Z. a7 K" D% x  G: K; J/ S        return ret;7 T5 S4 f" [$ c5 x! O/ K8 _# P* u; Z
}
& m- P/ a1 e+ P. d- l' N# D( _: ?! J7 U/ Z! ^8 ]& K( x
static void __exit led_platform_exit(void)
% j$ E5 _+ \1 C/ c{9 G- k- e' w* C2 f, S( }( @5 ~
        platform_device_unregister(&da850_evm_tl_leds_device);
9 p0 x5 v: Z$ ~4 a( L0 V6 E3 j! {" ?; a. J6 w/ z! o+ ^7 J# |
        printk(KERN_INFO "LED unregister!\n");
$ I6 z& e1 |8 W0 S}( C5 r/ N, S! E. U+ n1 X
" Y- b6 I( T; E. p( h# I7 e
module_init(led_platform_init);, {4 Z& g2 W, N; V  L
module_exit(led_platform_exit);5 ?% g; }6 d$ \

+ @6 \+ M- e* X7 T: VMODULE_DESCRIPTION("Led platform driver");
& D6 e6 B; R- Z$ k: {MODULE_AUTHOR("Tronlong");' f2 F% v9 ~3 @) I4 n+ H
MODULE_LICENSE("GPL");0 j+ i* p3 e' h. |" y
1 _2 P' T3 t2 o+ u
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-10-16 08:08 , Processed in 0.035584 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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